Webクリエイター能力認定試験の用語を覚えるためのPythonスクリプトイメージ

Python

html5_words.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Webクリエイター能力認定試験で憶えておきたい用語を出題するPythonプログラム
 
question = []  # 問題
answer = []  # 答え
 
# 問題と答えをリストに追加する関数
def set_mondai(mondai, kotae):
    question.append(mondai)
    answer.append(kotae)
 
# 問題データを作成
set_mondai("文書型宣言", "<!DOCTYPE html>")
set_mondai("ボックスの透明度", "opacity")
set_mondai("文字のサイズ", "font-size")
set_mondai("マージン", "margin")
set_mondai("マージン上", "margin-top")
set_mondai("マージン下", "margin-bottom")
set_mondai("マージン左", "margin-left")
set_mondai("マージン右", "margin-right")
set_mondai("パディング", "padding")
set_mondai("パディング上", "padding-top")
set_mondai("パディング下", "padding-bottom")
set_mondai("パディング左", "padding-left")
set_mondai("パディング右", "padding-right")
set_mondai("5ピクセル", "5px")
set_mondai("下ボーダーのスタイル", "border-bottom-style")
set_mondai("実線(ボーダー)", "solid")
set_mondai("左ボーダーの太さ", "border-left-width")
set_mondai("右ボーダーの色", "border-right-color")
set_mondai("二重線(ボーダー)", "double")
 
#set_mondai("", "")
 
# 問題を出題
mondaisu = len(question)
seikai = 0
for i in range(mondaisu):
    # 問題表示と解答入力
    print("({:2d}/{:2d}) {} --> ".format(i+1, mondaisu, question[i]), end="")
    kotae = input()
 
    # 英小文字に変換
    kotae = kotae.lower()
    answer[i] = answer[i].lower()
 
    # 判定
    if kotae == "q" or kotae == "Q"# 途中でやめる
        mondaisu = i
        break
    elif kotae == answer[i].lower():  # 正解
        print("〇")
        seikai += 1
    else# 不正解
        print("×")
 
# 正解数と正答率を表示
print("{}問中{}問正解しました".format(mondaisu, seikai))
print("正答率 {:.1f}%".format(seikai/mondaisu*100))

実行イメージ

コメント