Unit 8 (Unit 3) Computer Science Flashcards
(90 cards)
What are the three main building blocks of programming? (3)
- Sequence
- Selection
- Iteration
What is sequence in programming?
The specific order in which instructions or statements are executed in a program. It ensures operations happen in a logical and predictable order
What are data types?
Data types define the kind of data a variable can hold, such as numbers, text, or boolean values. They ensure data is processed and stored correctly by the system
How do data types enable appropriate storage?
Data types allow data to be stored in the right format, e.g. numbers as integers, characters as strings, etc
What is automatic validation in the context of data types?
The system automatically checks if the data matches the expected type and prevents errors
Note: This is a trick word in exams for CS they use validation which sounds confusing but it just means CHECKING
What is an integer in Pseudocode?
An integer is a positive or negative WHOLE number that can be used with mathematical operators (MUST be a whole number, cant be a decimal number)
What is a real number (float) in Pseudocode?
A real number is a positive or negative number WITH A DECIMAL and it can be used with mathematical operators (MUST be a decimal number, cant be a whole number)
What is a char in Pseudocode?
A char is a variable or constant that HOLDS a SINGLE character which can be letters, digits, or any printable symbol
What is a string in Pseudocode?
A string is a variable or constant that HOLDS MULTIPLE characters, which can be letters, digits, or any printable symbol. Strings can also be empty
What is a boolean in Pseudocode?
A boolean is a variable or constant that can have only two values: TRUE or FALSE
How do you get an integer input from a user with python (use age as an example)?
age = int(input(“Enter your age: “))
How do you get a real number (float) input from a user with python (use price as an example)?
price = float(input(“Enter the price: “))
What is Selection in programming?
Selection is a programming flow concept that allows the program to make decisions based on conditions
What is an If Statement?
It is a conditional statement that executes a block of code if its condition is true, otherwise it skips that block
What is an Else Statement?
An else statement provides an alternative to an if statement. It executes a block of code when the if condition is false
What is a Nested Statement?
Nested if statements allow one if statement inside another to check multiple conditions. They provide structure but can make code more complex.
What is a Case Statement?
Case statement checks a variable for different values and runs the code that matches the value
What is Selection in programming?
Selection allows a program to make decisions and choose different paths based on whether conditions are true or false
What do If Statements in programming allow?
It allows for branching outcomes in programs
What do Else Statements in programming allow?
It creates two possible paths, allowing the program to handle different scenarios efficiently
What do Case Statements in programming allow?
Helps people test a variable against several possible values. When a match is found, the corresponding code block executes
What are the benefits of selection in programming?
- Enables decision-making in programs.
- Makes applications user-responsive.
- Helps programmers create logical and efficient solutions.
What is Iteration in programming?
Iteration is the repetition of a block of instructions in a program. It can repeat a set number of times or until a condition is met, helping avoid repetitive code
What is a For Loop (Count Controlled)?
A for loop is a control flow statement that repeatedly executes a block of code a specified number of times, often used when you know how many times you want the code to run