Looks like no one added any tags here yet for you.
Variable
A named location in memory. Storing a single piece of data, which can be changed during run time.
Create a variable named year and assign it to the value of the current year as an integer
year = 2024 OR year = int(2024)
What is the value of num3 when this code has executed?
num1 = 5
num2 = 10
num3 = num1*num2
50
What is the value of num3 when this code has executed?
num1 = 21
num2 = 7
num3 = num1/num2
3.0 (results of division are stored as floats/real)
When programming what do we use the * operator for?
Multiplication
In the example below what does the + represent?
num3 = num1+num2
Addition
In the example below what does the + represent?
firstName = 'Ada'
surname = 'Lovelace'
fullName = firstName + ' ' + surname
Concatenation (joining of strings)
When programming what do we use the / operator for?
Division
When programming what do we use the - operator for?
Subtraction
When programming what do we use the == operator for?
Equal to
When programming what do we use the != operator for?
Not equal to
When programming what do we use the > operator for?
Greater than
When programming what do we use the >= operator for?
Greater than or equal to
When programming what do we use the < operator for?
Less than
When programming what do we use the <= operator for?
Less than or equal to
What python keyword do you use to accept data from user into your program?
Input
Write the code to ask the user for a number and store it as a variable named guess
guess = int(input("Enter your number: "))
#It doesn't matter if you wrote something else in the brackets but the "" do!
What python keyword do you use to output data from your program to your user?
Complete the code below to output Hello followed by their name:
name = input("What's your name?")
#your code goes here
print("Hello", name)
OR
print("Hello "+name)
What type of data does an integer hold?
Whole numbers (including negative numbers and 0)
What type of data does a float/real hold?
Decimal numbers
What type of data does a string hold?
Text, punctuation, numbers, symbols - anything stored in a ""
What type of data does a Boolean hold?
True / False
1 / 0
What is the output of the code below?
print(int(101.1))
101 (casting a float as an integer will remove the decimal numbers)
What is the output of the code below?
print(int(42.99))
42 (casting a float as an integer will remove the decimal numbers)
Define the term casting
Changing a variable's data type
What is a list used for?
Storing multiple pieces of data under a single name.
example:
Names
Lucki
Matt
Hiten
Aoife
Define the term sequence
Executing instructions in order
Define the term syntax error
An error that does cause the program to crash. An error in the rules of the programming language.
Define the term logic error
An error that does not cause the program to crash or produces unexpected output
Define the term IDE (Integrated Development Environment)
Allows programmers to write, test and run their programs.
Define the term selection
A comparison is made and the algorithm branches based on the result (can execute different pieces of code)
What is the output of this code?
number = 5
if number < 10:
number = number * 2
else:
number = number / 2
print(number)
10
What is the output of this code?
number = 18
if number < 10:
number = number * 2
else:
number = number / 2
print(number)
9
What do all selection statements start with?
if
What key term is missing from the code extract below?
if number < 5:
print("your number is less than 5")
____ number < 10:
print("Your number is less than 10")
elif
What key term is missing from the code extract below?
if number =< 5:
print("your number is 5 or less")
____:
print("Your number is greater than 5")
else
Does else have a condition?
No
How many If statements can you have in 1 block of selection statements?
1 (if starts a new selection block)
How many elif statements can you have in 1 block of selection statements?
Unlimited
Define the term iteration
Part of an algorithm is looped if a certain condition is met
Name the 2 types of loop
while and for
Name the boolean operators you can use in a program
AND, OR, NOT
Why should you use comments in your code?
Make it easier to follow the logic of your code.
Explain how the code works.
Add details like the version number.
To help someone else edit your code or to help someone else edit your code (maintainability)
What numbers will this code output?
for count in range(0,10):
print(count)
0
1
2
3
4
5
6
7
8
9
A for loop is what type of loop?
Counter controlled Iteration / loop
A while loop is what type of loop?
Conditional iteration / loop
Define compression
Reducing the size of a fil4
Name the 2 types of compression
Lossy and Lossless
Define lossy compression
Compression in which data is lost and cannot be retrieved in its original form.
Define lossless compression
Compression in which no data is lost and all data can be retrieved in its original form.
What type of file would you use lossy for?
Used for media (images, videos, sound) where a loss of detail isn't noticeable to the eye/ear.
What type of file would you use lossless for?
Text and programs as a loss of data means the file wouldn't work correctly.
Why do we compress files?
Reduce the file size
Less data means the file is quicker to send
Means you can store more files on secondary storage
Define the term bit
A single binary digit, either 1 or 0
Define the term byte
8 bits of data
Define the term nibble
4 bits of data
How many nibbles in a byte?
2 (1 nibble is 4 bits, 1 byte is 8 bits therefore 8 / 4 is 2)
When storing data, what does KB stand for?
Kilobyte
When storing data, what does GB stand for?
Gigabyte
When storing data, what does MB stand for?
Megabyte
How many bytes in a kilobyte?
1024
Order these storage units from smallest to biggest: nibble, bit, kilobyte, gigabyte, byte, megabyte
bit, nibble, byte, kilobyte, megabyte and gigabyte
Order these storage units from largest to smallest: nibble, bit, kilobyte, gigabyte, byte, megabyte
Gigabyte, megabyte, kilobyte, byte, nibble and bit
How many kilobits in a megabyte?
1024
How many megabytes in a gigabyte?
1024