Fundamentals of Programming

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/47

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

48 Terms

1
New cards

What is a character

A letter, number or special character typically represented in ASCII.

2
New cards

What is a string

Anything enclosed in quote marks

3
New cards

The round function

Rounds a number to a specified number of decimal places.

round(num, 2) - rounds a number to two decimal places

4
New cards

The trunc function

Truncates real numbers to the nearest whole number.

5
New cards

How do you find the length of a string

len(string)

6
New cards

How do you concatenate two strings

‘str1’ + ‘str2’ = ‘str1str2’

7
New cards

What are variables

identifiers given to memory locations whose contents will change during the course of the program.

8
New cards

Declaring constants

const ConstantName = value

9
New cards

What is sequence

two or more statements following one after the other.

10
New cards

What is assignment

Assigning a value to a variable.

11
New cards

What is selection

Statements which choose which statement to be executed next depending on some condition.

12
New cards

What is iteration

Repetition of an instruction or series of instructions.

13
New cards

Two types of iteration

Indefinite: continues until some specified condition is met (WHILE)

Definite: The number of times the loop is to be executed is specified in advance (FOR)

14
New cards

What is an array

an ordered, finite set of elements of a single type.

15
New cards

1 Dimensional arrays

myArray ← [1, 2, 3, 4]

16
New cards

2 Dimensional Arrays

myArray ← [[1, 2, 3, 4, 5]

[10, 20, 30, 40, 50],

[100, 200, 300, 400, 500]]

17
New cards

What is a subroutine

A named block of code which performs a specific task within a program.

18
New cards

Name two types of subroutine

Functions and Procedures

19
New cards

What are programming languages?

formal languages comprising a set of instructions that can be used to produce various kinds of output.

20
New cards

What is an algorithm?

An algorithm is a step-by-step procedure or formula for solving a problem.

21
New cards

What do we mean by data types?

classifications of data that tell the compiler or interpreter how the programmer intends to use the data.

22
New cards

What is control flow?

The order in which individual statements, instructions, or function calls are executed or evaluated in a program.

23
New cards

What is a syntax error?

when the code does not adhere to the grammatical rules of the programming language, preventing the program from running.

24
New cards

What does debugging mean?

The process of identifying errors from computer software or hardware.

25
New cards

What is Object-Oriented Programming (OOP)?

A programming paradigm based on the concept of 'objects', which can contain data in the form of fields (attributes or properties) and code in the form of procedures (methods).

26
New cards

What are the four main principles of OOP?

Encapsulation, Abstraction, Inheritance, and Polymorphism.

27
New cards

What is Encapsulation?

The bundling of data and methods that operate on that data within a single unit (object), restricting access to some of the object's components.

28
New cards

What is Abstraction?

The concept of hiding the complex reality while exposing only the necessary parts of an object.

29
New cards

What is Inheritance?

A mechanism wherein a new class is derived from an existing class, inheriting attributes and methods of the base class.

30
New cards

What is Polymorphism?

The ability of different classes to be treated as instances of the same class through a common interface, allowing methods to do different things based on the object it is acting upon.

31
New cards

What is a Class in OOP?

A blueprint for creating objects, defining a set of attributes and methods that the created objects will have.

32
New cards

What is an Object in OOP?

An instance of a class that contains actual values instead of variables.

33
New cards

What is a Constructor?

A special method used to initialize an object when it is created.

34
New cards

What is Method Overriding?

A feature that allows a subclass to provide a specific implementation of a method that is already defined in its superclass.

35
New cards

What is Method Overloading?

The ability to create multiple methods with the same name but different parameter lists within the same class.

36
New cards

What is an Interface?

A reference type in OOP that defines a contract which classes can implement, providing a way to achieve abstraction and multiple inheritance.

37
New cards

What is a Superclass?

The class from which other classes (subclasses) inherit, often referred to as the parent class.

38
New cards

What is a Subclass?

A class that inherits from another class (the superclass), which can extend or modify the inherited behavior.

39
New cards

What is a Stack Frame?

A stack frame is a data structure that contains information about a function call, including local variables, parameters, return address, and saved registers.

40
New cards

What is the purpose of a Stack Frame?

The purpose of a stack frame is to manage function calls and returns, providing a way to store local state information for each invocation.

41
New cards

What information does a Stack Frame typically contain?

A stack frame typically contains the function's parameters, local variables, return address, and any bookkeeping information required for the function's execution.

42
New cards

How does a Stack Frame grow?

A stack frame grows downwards in memory (from high memory addresses to low memory addresses) as additional function calls are made.

43
New cards

What happens when a function is called?

When a function is called, a new stack frame is created and pushed onto the stack, storing the current context of execution.

44
New cards

What is the role of the Return Address in a Stack Frame?

The return address in a stack frame is used to determine where control should return after a function has finished executing.

45
New cards

What is a stack overflow?

A stack overflow occurs when there is more data pushed onto the stack than it can hold, typically caused by excessive function calls or recursion.

46
New cards

How do Stack Frames interact with Recursion?

With each recursive function call, a new stack frame is created, allowing each call to maintain its own set of local variables and execution context.

47
New cards

What is the Call Stack?

The call stack is a stack data structure that stores information about active subroutines (functions) in a program, including their stack frames.

48
New cards

What is the difference between the Call Stack and the Heap?

The call stack is used for static memory allocation of stack frames, while the heap is used for dynamic memory allocation, allowing more flexible memory use.