-02 Basic Components in C-C-- and Python

Created by Jacqueline

p.5

What are the different levels of abstraction in programming?

Click to see answer

p.5
LevelDescription
Machine CodeHexadecimal or binary values representing the lowest-level instructions executed by hardware.
Assembly CodeLow-level mnemonic instructions that map closely to machine code but are slightly more readable.
High-Level ViewSource code written in high-level languages with variables, functions, and control structures that are portable and more human-readable.

Click to see question

1 / 4
p.5
Levels of Abstraction in Programming

What are the different levels of abstraction in programming?

LevelDescription
Machine CodeHexadecimal or binary values representing the lowest-level instructions executed by hardware.
Assembly CodeLow-level mnemonic instructions that map closely to machine code but are slightly more readable.
High-Level ViewSource code written in high-level languages with variables, functions, and control structures that are portable and more human-readable.
p.5
4
6
Key Characteristics of Variables

What are the key characteristics of variables?

  1. Identifier: A variable has a name used to reference it in code.
  2. Store Value: Holds a value that can change during execution.
  3. Data Type: Specifies the kind of value the variable can hold (e.g., int, float, object).
  4. Scope: Describes where the variable is visible (global or local).
  5. Lifetime: The duration the variable exists in memory (e.g., program lifetime for globals, function execution for locals).
p.5
4
6
Key Characteristics of Variables

What rules must an identifier follow in C/C++ and Python?

  • Must start with a letter (A–Z or a–z) or an underscore (_); cannot start with a digit.
  • Can contain letters, digits, and underscores (e.g., my_variable, _var, variable1).
  • Case-sensitive (e.g., Variable and variable are distinct).
  • Cannot use reserved keywords from the language (e.g., if, else, while, for).
p.8
4
Comparison between C/C++ and Python

What are the key differences in identifier naming and variable typing between C/C++ and Python?

FeatureC/C++Python
Identifier NamingMust start with letter or underscore, followed by letters, digits, underscores.Same, but Python's dynamic nature makes naming overall more flexible in use.
Variable TypingStatic typing: types are declared and fixed (e.g., int, float).Dynamic typing: variables take the type of their current value and can change.
Integer TypesFixed-size signed/unsigned integers (char, int, long, etc.).Arbitrary precision integers (no fixed-size limit).
Boolean Typebool type with values true/false.bool class with values True/False.
Floating Pointfloat, double, long double with differing precision.float is double-precision (equivalent to C/C++ double).
Study Smarter, Not Harder
Study Smarter, Not Harder