Computering Flashcards
What are the 5 variable naming rules?
- You can only use letters, numbers or underscores
- Your variable must start with a letter (underscores are for special occasions, don’t usually use)
- Python is case sensitive (spam, sPam, Spam are all different)
- Variables should be lowercase
- You are advised on Python to separate words with underscore (My_list) but camel case is fine also (myList)
What is RAM?
Random Access Memory
Each memory location is the RAM has an address (like 346701)
What is a variable?
A name pointing to a memory address which contains a value and has a data type
What is an integer?
A whole number
67
What is a float?
Short for a floating point number, decimal
12.5
What is a boolean?
True is a boolean data type.
“If it’s raining put up your umbrella.” The first part: “If it’s raining” is a boolean test. True or false answers this. If it’s true, put your umbrella up. If it’s false don’t
What is a string?
Not to be confused with a word, it is a string of characters
Jane
&@£!”
Why is knowing the data type important?
Python can work out how much memory to put aside.
It will tell Python which operations can be carried out on the data. For example, you can’t have lowercase
number and you can’t divide a word
What is declaring a variable?
Saying what the data type is when you create a variable (you don’t have to do this in python)
In a mathematical sum, how do you get decimal places in your answer?
You must make the variables doing the sum be a string.
24/13.0 = 1.84615384615
What is Sequence?
Each instruction is carried out in order. No action can be skipped
What is Selection?
A question is asked which produces a Boolean value and the action that follows depends on the answer
What is Iteration?
Executing the same set of instructions a given number of times or until a specified result is obtained (loops)
What is the difference between == and =?
== means equals to
= means python will assign a value to a variable
Explain If
If is a keyword followed by a condition followed by a colon
Explain Else
Else means everything else, followed by a colon
Explain Elif
Elif is a keyword followed by a condition followed by a colon. It means else if
What does a colon mean?
Python expects a block of code (instructions on what to do)
Explain While Loops
While a condition is true do something and keep looping until the condition has become false (or the user has had all their guesses). You need to decide what your string is, variable and calculation
Explain Nested While Loops
A while loop within a while loop. After the first while loop colon, everything will repeat to the second while loop until the code breaks
What is < ?
Less than
What is > ?
More than
What is <= ?
Less than or equal to