more theory Flashcards

(10 cards)

1
Q

Briefly explain the difference between variables and identifiers.

A

A variable is a named memory location used to store data.
An identifier is the name given to variables, functions, classes, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe 4 core datatypes in Python.

A

Numeric (int, float, complex)
Text (str)
Boolean (bool)
Sequence (list, tuple, range)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Difference between continue and break

A

break: Immediately exits the loop when a condition is met.
continue: Skips the current iteration and moves to the next loop cycle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference between pop, del, and clear in dictionaries

A

pop(key): Removes the specified key and returns its value.
del dict[key]: Deletes the key-value pair without returning the value.
clear(): Removes all items from the dictionary, leaving it empty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Briefly describe three String operations in Python.

A

Concatenation – Combines two or more strings into one using the + operator.
Slicing – Extracts a part of the string using index positions.
Case Conversion – Changes the case of a string using methods like upper() or lower().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain four(4) list methods in Python.

A

append() – Adds a single element to the end of the list.
extend() – Adds multiple elements (from another list or iterable) to the end of the list.
insert() – Inserts an element at a specified position in the list.
remove() – Removes the first occurrence of a specified value from the list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the advantages of Object-oriented programming over procedural programming?

A

Easier to manage – Code is grouped in objects and classes making it easier to update
Reusability – You can reuse code using classes and object through inhertiance
Better organization – Makes big programs easier to understand.
Protects data – Only allows access to what’s needed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List four file processing tasks in Python.

A

Opening a file – Accessing a file for reading, writing, or appending.
Reading from a file – Retrieving data from a file.
Writing to a file – Saving data into a file.
Closing a file – Properly closing the file to free resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Briefly explain polymorphism in Object-oriented programming.

A

Polymorphism:
“Polymorphism” refers to the ability of some bit of code to handle different data
types.
Polymorphism means the ability of different classes to respond to the same method or function call in their own way allowing flexibility in code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Briefly explain inheritance in Object-oriented programming.

A

Inheritance:
Inheritance allows a new class to acquire properties and methods from an existing class (parent), enabling code reuse and hierarchy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly