Python Flashcards
What is a string variable?
A variable that contains words.
How do you change a variable to an integer?
You put ‘variable = int(variable)’
How do you write a conditional statement?
You use an if statement
What does ‘len’ do?
It tells you how many characters there are in the variable
How do you print something?
You use the function ‘print’
How do you combine if and else?
Elif
How do you get someone to input text?
You use the ‘input’ function
What are the three types of variable?
String, Integer and Float
What is an integer?
A number that doesn’t involve decimals.
What is a float?
A number that does involve decimals.
How do you start a new line?
Write \n.
What is a syntax error?
An error in the code which means that the computer cannot carry out any of the code.
What does ().upper do?
It makes all the characters in the string upper case.
What are the comparations you can make in an if statement?
<=, >=, ==, !=
How do you repeat actions in Python?
You can say while this is true: (closed loop) or for x in this array: (open loop)