11.1 Programming.basics incompl Flashcards
What is a constant in programming?
A named value that cannot change during the execution of a program. It must always be assigned a value when declared.
What is a variable in programming?
A named value that can change during the execution of a program. It is good practice to declare and initialise variables before use.
What is a library routine in programming?
A tested and ready-to-use routine available in the development system of a programming language that can be incorporated into a program.
What is a procedure in programming?
A set of statements grouped together that can be easily called in a program. Unlike a function, a procedure does not necessarily return a value.
What is a function in programming?
A set of statements grouped together that can be easily called in a program. Unlike a procedure, a function always returns a value.
Why is it good practice to assign initial values to variables and constants?
To ensure the programmer is certain of the starting values, preventing undefined behaviour during data manipulation.
How does Python handle constants and variables differently from other programming languages?
Python does not require separate declarations or enforce a distinction between constants and variables. Instead, assigning a value at the start ensures correct data type usage.
What are some examples of built-in mathematical functions in programming?
DIV(x, y)
returns the integer part of a division (e.g., DIV(10, 3) → 3
).MOD(x, y)
returns the remainder of a division (e.g., MOD(10, 3) → 1
).
Why are strings useful in programming?
Strings are versatile for storing data and are commonly used for comparing data like passwords, usernames, and other textual information.
What are some examples of string manipulation functions in Python?
len(string)
returns the length of the string.string[0]
accesses the first character.string[-1:]
accesses the last character.
What does an Integrated Development Environment (IDE) typically include?
An IDE usually includes:
- A standard library of functions and procedures.
- An interpreter and/or compiler.