What is the best data type to store a person's name?
String
(A string can contain a person's name as text)
What does IPO stand for?
Input, Process, Output
What is a variable used for?
A variable is used to store data that can be accessed or changed by a program
What is the output?
userName = "Robert"
if userName == "Rober":
print("Hello Rober")
else:
print("Hello Robert")
Hello Robert
Name at least 5 programming languages.
Java, Lua, Python, Scratch, C#, C++, C, Javascript, CSS, HTML
Name the 4 basic Data types.
- String
- Integer
- Boolean
- Float
A program asks the user for their age. What stage in the IPO is this?
Input
x = 19
x += 4
What is the value of x?
What is the output?
for i in range(7):
print(i)
0
1
2
3
4
5
6
How do you make comments in Python?
Place a Hashtag (#) at the beginning of the line
What is the difference between Int and Float?
Float can handle decimals; Int can only handle whole numbers.
A program calculates 10 + 5. What stage in the IPO is this?
Process
Which is a valid example of a variable name?
A. student_name
B. student name
C. 123student
D. student-name
A. student_name
(A variable cannot start with a number and cannot have spaces. Underscore becomes the exception.)
x = 0
for i in range(13):
x=(x+1)%3
print(x)
3
Why do languages like Java use a semicolon to end the line?
To tell the compiler where a single instruction ends and the next begins.
What are the main 4 data types?
String, Bool, Int, Float
For a program that calculates the area of a rectangle, what could the inputs be?
The length and width of the rectangle.
What data type would "is_student = True" use?
Boolean.
x = 4
for i in range(5):
x += i
print(x)
14
What is recursion?
Recursion is a programming technique where a function calls itself directly or indirectly to solve a problem. It must always contain a base case to stop the loop and prevent a stack overflow.
Why do we need specific data types in programming?
Data types help programs stay organized, avoid mistakes, and handle data correctly
For a calculator, identify the input, process, and output
Input: Numbers and an operation, such as 10 + 5
Process: Add the numbers
Output: 15
Why should variable names be meaningful?
easier to understand and maintain, especially in group work, and to avoid confusion with other variable names.
x = 4
for i in range(67):
if x <= 4:
x += 1
else:
x -= 1
print(x)
5
What is the difference between a compiler and an interpreter?
A compiler translates the entire source code into machine code all at once before execution (e.g., C, C++), creating a standalone executable file.
An interpreter translates and executes the code line-by-line at runtime (e.g., JavaScript), which makes debugging faster but execution slower.