Term 2 Python Flashcards
Is the next line a valid print statement?
print(“Hello World”)
Yes, it prints ‘Hello World’ on screen
Is the next line a valid print statement?
print()
Yes, it prints a blank line (useful for spacing information out on screen).
Are the next 4 lines a valid print statement? print(''' Hello world ''')
Yes, using triple quotes at the start and the end keeps the formatting (layout) so this prints as:
Hello
world
Is the next line a valid print statement?
print(Hello World)
No - it is missing speech marks and so will not print.
Would this code allow the user to enter the radius of a circle which could be used in a calculation?
radius = input(“Please enter a number”)
No - the value input would be a string and would not work in a calculation.
Would this code allow the user to enter the radius of a circle which could be used in a calculation?
radius = value(input(“Please input a number”))
No - value is not understood by Python
Would this code allow the user to enter the radius of a circle which could be used in a calculation?
radius = float(input(“Please input a number”))
Yes - the value input by the user is “cast” (changed) to a floating point number (number with a decimal).
Would this code allow the user to enter the radius of a circle which could be used in a calculation?
radius = number(input(“Please input a number”))
No - number is not understood by Python
What data type is used for several characters in a row, e.g. “value34” or “End of Game!”?
string
What data type is used for whole numbers, e.g. 78 or -99?
integer (int for short)
What data type is used for numbers with a decimal point, e.g. 3.14 or 66.9?
floating point number (float for short)
What data type is used to hold values that can only be True or False?
boolean (bool for short)
Can the command below be used to allow the user to
enter data which can be saved into a variable?
enter
No enter is not a command word recognised in Python
Can the command below be used to allow the user to enter data which can be saved into a variable?
input
Yes:
variable = input(“please give me some data “)
Can the command below be used to allow the user to enter data which can be saved into a variable?
print
No this just prints out but does not allow entry of data