CompSci Autumn 2022/23 Python Flashcards
1.1 What is input?
Input is where the user enters data. This could be the user typing data in.
1.2 What is output?
Output is where the program shows the user data. This could be a message on screen.
1.3 How do you output the message “Hello world”?
print(“Hello world”)
1.4 How do you let a user type in data?
age = datatype(input(“Enter age:”)
2.1 What is a variable?
In a computer program, a variable is used to store data.
2.2 How do you make the program store the user’s input?
name = datatype(input(“Enter name:”) will store the user’s input in a variable called ‘name’.
2.3 How do you output the contents of a variable?
print(name) will output the data held in the variable ‘name’.
2.4 int data type
Integer – stores whole numbers
2.5 str data type
String – can store a sequence of characters
2.6 float data type
Can store decimal values e.g. 3.5
2.7 bool data type
Can store a True or False value only.
3.1 What is selection?
Selection is where a program checks a condition, and the program responds accordingly.
3.2 What is a condition?
The condition is an expression that will result in a True or False value e.g. 1 = 2 will result in False.
3.3 Indentation
Refers to space at the beginning of a code line. In Python indentation is used to indicate a block of code.
3.4 How would you make a program show “Well done” if the variable score is above 10?
if score > 10: print (“Well done”)