Unit 8 (Unit 3) Computer Science Flashcards
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 is pseudocode?
A simplified, informal way of describing an algorithm or program logic using plain language. It focuses on structure and flow without specific programming syntax
What is a high-level language?
A type of programming language designed to be easy for humans to read and write
What is syntax in programming?
The set of rules that define the structure and format of valid statements in a programming language
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
How do data types enable effective manipulation?
Data types allow operations like mathematical calculations on numbers
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 Python?
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 Python?
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 Python?
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 Python?
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 Python?
A boolean is a variable or constant that can have only two values: TRUE or FALSE
How would you DIRECTLY assign an integer in python (give example)?
Score = 25
How would you DIRECTLY assign a real number (float) in python (give example)?
Price = 2.67
How would you DIRECTLY assign a char value in python (give example)?
Grade = ‘A’
How would you DIRECTLY assign string values in python (give example)?
Name = “Kyllian Mbappe KM9”
How would you DIRECTLY assign boolean in python (give example)?
logged_in_now = True
(this just represents a boolean showing login status)
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 Sequence in programming?
Sequence refers to the order in which instructions or steps are executed in an algorithm. The correct order is crucial because an incorrect sequence can lead to incorrect results or unnecessary steps
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