# -*- coding: utf-8 -*-
"""
fill-in-the-blanks1.py
"""
# -*- coding: utf-8 -*-
"""
p1
"""
level1 = '''The __1__ command can print out any types of a variable. __2__ defines a function that could be
called out at any place in the document. A __3__ is a group of strings, variables or numbers. __3__ can also be
printed by the __1__ command. __4__ is the statement of true or false.'''
level2 = '''A ___1___ is created with the def keyword. You specify the inputs a ___1___ takes by
adding ___2___ separated by commas between the parentheses. ___1___ by default return ___3___ if you
don't specify the value to return. ___2___ can be standard data types such as string, number, dictionary,
tuple, and ___4___ or can be more complicated such as objects and lambda functions.'''
level3 = '''__1__ , __2__ , __3__ , all belongs to the if statement. __1__ will be used at the beginning of the
if statement, __2__ will be used in the middle between the __4__ and the __5__ statement. '''
variables1 = ["print", "def", "list", "boolean"]
variables2 = ["function", "parameter", "false", "list"]
variables3 = ["if", "elif", "else", "first"]
d = "__1__"
e = "__2__"
f = "__3__"
g = "__4__"
h = "__5__"
def replacevar(string, variable, inputa, finish):
string.split()
while True:
if inputa == variable[0]:
string = string.replace(d, inputa)
finish = ""
finish = finish.join(string)
return finish
break;
else:
print ("Your Answer is incorrect, pls try again")
return True
level = input("Which level do you want to play? (1, 2 or 3)")
if level == "1":
print (level1)
useranswer = input("Please enter the value for variable NO.1: ")
replacevar(level1, variables1, useranswer, finish1)
print (finish1)
Python-Code wie oben, das ist nur der erste Teil des Programms, das Sie in den freien Raum und ersetzen Sie die ..... mit dem Wort, das Sie eingegeben füllen fragt, ob Ihr Antwort ist richtig. Aber als ich das Programm startete, nachdem ich 1 eingegeben hatte, zeigte die Frage wie erwartet, aber nachdem ich "print" (ohne "") für die Antwort für die erste Variable "" eingegeben hatte, druckte es nicht Zeichenfolge mit ersetzten Wörtern.-Code doesnt Druck etwas
Es scheint etwas zu fehlen, die Variable 'finish1' ist nirgends definiert. – fjarri