Topic 8 Flashcards
What is a program?
A set of instructions that a computer follows to perform a task.
What is programming?
The process of writing instructions for a computer to execute.
What are the elements of programming?
- Variables
- Constants
- Data types
- Operators
- Control structures
Why is programming important?
It enables the creation of software applications that drive technology.
What would the world look like without programming?
Limited technology and automation; reliance on manual processes.
What is the first program typically written in Python?
print(“Hello world”)
What is a variable in programming?
A storage location identified by a name that holds a value.
What are the basic data types in Python?
- INTEGER
- FLOAT
- STRING
- BOOLEAN
- DATE
- CHARACTER
What does the command ‘print(“hello”, “how”, “are”, “you”)’ do?
Prints the words with spaces in between.
How do you take string input in Python?
name=input(“What is your name?”)
What is a conditional statement?
A statement that executes different actions based on whether a condition is true or false.
What is the structure of an IF statement?
IF <condition> THEN <action> ELSE <alternative></alternative></action></condition>
What is the purpose of the ‘else’ clause in conditional statements?
To define an alternative action when the condition is false.
What does the ‘==’ operator do?
Checks if two values are equal.
Fill in the blank: In Python, __________ is used to check if a value is not equal to another value.
!=
What is the difference between a while loop and a repeat until loop?
While loop checks the condition before executing; repeat until checks after.
What is the syntax for a for loop in Python?
for i in range(start, end):
What is the purpose of the ‘break’ statement in loops?
To exit the loop prematurely.
What is iteration?
The process of executing a set of statements repeatedly.
What is a pre-condition loop?
A loop where the condition is tested before executing the loop body.
What is a post-condition loop?
A loop where the condition is tested after executing the loop body.
What does the modulus operator (%) do?
Returns the remainder of a division operation.
Fill in the blank: In Python, __________ is used to create a loop that iterates a specific number of times.
for
What is selection in programming?
The process of choosing which action to perform based on conditions.