CSP Python Intro Notes
important terms, commands, etc.
.ipynb = python file
print("Hello World!") #simple hello world print command
msg = input("Enter a greeting: ") #input and output command
print(msg)
print("Enter Something") #input and output command 2.0
s = input()
print("You wrote:",s)
def question_and_answer(prompt): #question and answer command
print("Question: " + prompt)
msg = input()
print("Answer: " + msg)
question_and_answer("Do you like food?")
question_and_answer("Do you play a sport?")
question_and_answer("What's your favorite class?")
import getpass, sys #
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
questions = 3
correct = 0
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_with_response("Are you ready to take a test?")
rsp = question_with_response("What command is used to include other functions that were previously developed?")
if rsp == "import":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What command is used to evaluate correct or incorrect response in this example?")
if rsp == "if":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")
if rsp == "expression":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))