Data Types
Specifies the kind of data that can be stored and manipulated within a program. Examples: integers, real numbers, Booleans, characters, and strings.
Integer
Whole numbers without a fractional part, used for counting and indexing. Example: 5, -42
Real (Float)
Numbers that can contain a fractional part, used for measurements and continuous data. Example: 3.14, -0.001
Boolean
Represents true or false values, used for logical operations and conditional statements. Example: True, False
Character
A single alphanumeric character, used for text processing at a granular level. Example: 'A', '3'
String
A sequence of characters, used for text and sentences. Example: "Hello", "123ABC"
Variable Declaration
Introduces a variable by specifying its name and type. Example: age = 25
Constant Declaration
Defines a value that cannot be changed during program execution. Example: PI = 3.14159
Assignment
Assigns a value to a variable. Example: name = "Alice"
Iteration
Repeats a block of code multiple times or until a condition is met.
Selection
Makes decisions within a program based on conditions. Example: score = 85
Subroutine (Procedure/Function)
Encapsulates a block of code that performs a specific task. Example: def calculate_area(width, height): return width * height
Sequence
Default mode of execution where statements run one after the other.
Nested Iteration
Repeats a sequence of instructions within another iteration.
Nested Selection
Makes decisions within a program based on conditions within another selection.
Named Constants and Variables
Used to make programs easier to read and maintain. Constants ensure values do not change accidentally, while variables hold data that can change.
Meaningful Identifier Names
Improve code readability and maintainability by using descriptive names and consistent naming conventions. Examples: total_sum, user_age, calculate_area
Arithmetic Operations in Programming
Include addition, subtraction, multiplication, real division, integer division, and remainders.
Modular Arithmetic
Used in scenarios requiring periodicity, such as clock arithmetic.
Relational Operations
Include common relational operators like Equal To, Not Equal To, Less Than, Greater Than, Less Than or Equal To, and Greater Than or Equal To.
Boolean Operations
Include common Boolean operators like NOT, AND, and OR.
Data Structures
Ways of organizing and storing data efficiently. Examples: Arrays, Records (Structures).
Records
Used to group different data types under one name, allowing for a structured way to represent real-world entities.
Arrays
A collection of elements of the same type, stored in contiguous memory locations.
One-Dimensional Array
Example: numbers = [1, 2, 3, 4, 5]
Two-Dimensional Array
Example: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Efficiency
Data structures like arrays allow for efficient storage and retrieval of data.
Organization
Records provide a structured way to store related data fields.
Simplicity
Arrays and records simplify the implementation of algorithms and data manipulation operations.
User Input
Obtaining user input from the keyboard in Python using the input() function.
Output Data
Using the print() function in Python to display data and information on the computer display.
Length
Using the len() function in Python to get the length of a string.
Position
Accessing individual characters in a string by their position using zero-based indexing.
Substring
Extracting a part of a string.
Concatenation
Joining two strings together.
Convert Character to Character Code
Using ord() to get the ASCII value of a character and chr() to get the character from an ASCII value.
String Conversion Operations
Converting between different data types like string to integer, real to string, etc.
Generating Random Integer
A specified range using randint() to generate a number from the random module.
Generating Random Float
Generating a random number between 0.0 and 1.0 using the random() function.
Random Choice from a Sequence
Choosing a random element using the choice() function.
Shuffling a Sequence
Randomly shuffling the elements of a sequence using the shuffle() function.
Simulation
Simulating random events or behaviors.
Games
Generating random game scenarios, outcomes, or choices.
Statistical Sampling
Generating random samples for statistical analysis.
Cryptographic Applications
Creating cryptographic keys or initialization vectors.
Subroutine
A named 'out of line' block of code that can be executed by writing its name in a program statement.
Procedures
Subroutines that perform actions but do not return a value.
Functions
Subroutines that perform actions and return a value.
Modularity
Breaks programs into manageable sections. Each subroutine performs a specific task, making it easier to understand and manage.
Simplified Maintenance
Easier to update and fix code. Changes in a subroutine affect all calls to it, reducing the need to make multiple updates.
Improved Readability
Makes code more organized and easier to understand. Subroutines give structure and clarify the purpose of each part of the code.
Enhanced Collaboration
Different programmers can work on different subroutines simultaneously. This is particularly useful in large projects.
Parameters
Variables listed as part of a subroutine's definition, allowing data to be passed into the subroutine.
Data Passing by Value
A copy of the data is passed to the subroutine.
Data Passing by Reference
A reference to the actual data is passed, allowing modifications.
Returning Values from Subroutines
Subroutines can return a value to the calling routine using the return statement.
Local Variables in Subroutines
Variables declared within a subroutine, accessible only within that subroutine.
Structured Approach
A method of programming that emphasizes breaking a program into smaller, manageable, and reusable modules or subroutines.
Common Validation Checks
Includes minimum length check, empty string check, and range check for validating input data.
Simple Authentication Routines
Example of an authentication routine that checks username and password for validity.
Testing
Involves running a program to find errors or confirm expected behavior under different conditions.
Types of Errors
Syntax errors and logic errors are common types of errors in programming.
Records (Structures)
Used to group different data types under one name, allowing for a structured way to represent real-world entities. This is akin to a form where different fields (like name, address, phone number) are filled out for each individual.
Syntax Error
Errors due to incorrect code syntax
Logic Error
Errors where program runs but produces incorrect results