oop Flashcards

1
Q

the traditional type looping of iteration in python is the —- which enables a piece of code to execute repeatedly So long as some given condition is true. It executes a block of statements continuously until a specified condition ends up true once
the condition becomes false the program will execute the statement immediately after the loop

A

while loop

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

is a little different from while sense that it work more like an iterative procedure and for keyword

A

for Loop

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

is an iterative sequence that works on List, string dictionaries, tuples, set array, and Etc.

A

for Loop

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

this code for Loop iterates over a string and prints each character on a new line. The loop assigns each character to the variable I and continues until all characters in string has been displayed

A

for loop with strings

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

the inner loop will be executed each iteration if the value of outer loop is true

A

nested loop

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

sometimes ———- used in multi-dimensional array or depends on the problem outcome you want to have

A

nested looping

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

Stops the code immedietly when its met or encountered

A

break statement

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

It skips the current iteration and proceed to the next iteration

A

continue statement

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

a —— is a data structure that holds a sequence of elements such as numbers strings or even other lists it’s like a collection of related items similar to a list of things you’d write down like a to-do list or shopping list

A

list

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

are mutable which means you can change them after you create them you can add new elements remove elements or modify existing ones it’s like having a flexible bag you can toss things in take things out or rearrange them as needed

A

lists

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

the items inside a list are —–. This means that the position of each element is fixed so you can access items using their index position in the list starting from zero for the first item think think of it as a numbered shelf where each item has a specific Place

A

ordered

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

are immutable sequences in Python that is once created elements cannot be changed added to or removed from it

A

tuples

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

are useful to group together multiple values like lists but have the added property that their content cannot be modified they are defined by putting elements inside parentheses separated by commas

A

tuples

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

A —- in Python is an unordered collection of unique elements.

A

set

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

are defined using curly brace or by calling the set function

A

Sets

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

unlike lists or tuples, it does not allow duplicate values. this makes them useful when you need to store a collection of distinct item or when you want to perform common set operations like Union intersection or difference

A

set

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

characteristics of a sets

A
  1. unordered
  2. mutable
  3. no duplicates
  4. heterogenous
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

is a fundamental iterative structure in Python programming that allows you to repeat a code block as long as a specified condition is true.

A

The while loop

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

is a fundamental construct in Python programming that enables you to repeat a code block as long as a specified condition remains true.

A

The while loop

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

is a powerful iterative structure in Python that allows you to repeat a code block a specific number of times or iterate over elements in a sequence (e.g., a list, tuple, string, etc.)

A

The for loop

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

is a temporary variable that takes each element from the sequence one by one, and the code block is executed for each element in the sequence.

A

item

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

can be any iterable object, such as a list, tuple, string, or range, that contains multiple elements

A

The sequence

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

is a versatile iterative structure in Python that allows you to repeat a code block for a specific number of times or iterate over elements in a sequence.

A

The for loop

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

In Python, just like in C, it is possible to use loops within loops, which is known as

A

nested loops

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

provide a powerful way to perform repetitive tasks that require multiple iterations.

A

Nested loops

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

consist of an outer loop and one or more inner loops.

A

Nested loops

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

in Python provide a way to execute loops within loops, allowing for the iteration and manipulation of data on multiple levels.

A

Nested loops

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

is used to prematurely terminate the execution of a loop.

A

the break statement

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

is typically placed inside an if statement or a conditional block to check a specific condition.

A

The break statement

30
Q

is crucial in programming as it provides control over loop execution.

A

The break statement

31
Q

in Python provides a way to terminate the execution of a loop prematurely.

A

The break statement

32
Q

plays a crucial role in optimizing program execution, improving efficiency, and implementing complex control flow within loops.

A

The break statement

33
Q

is used to skip the current iteration of a loop and move to the next iteration.

A

the continue statement

34
Q

in Python allows you to skip the current iteration of a loop and move to the next iteration.

A

The continue statement

35
Q

is a versatile and fundamental data structure that allows you to store a collection of elements of different types.

36
Q

provide a convenient way to organize and manipulate data as a sequence of items.

37
Q

purpose of lists

A
  1. grouping related data
  2. dynamic storage and retrieval
  3. Iteration and processing
38
Q

are a powerful and flexible data structure in Python that allow you to store and manipulate collections of elements efficiently.

39
Q

importance of list

A
  1. dynamic and flexible
  2. data organization
  3. iteration and processing
  4. versatility
  5. widely used
40
Q

is an ordered collection of elements enclosed in parentheses ( )

41
Q

are immutable, meaning their elements cannot be modified once they are defined

42
Q

practical applications of tuples

A

data integrity
returning multiple values
named tuples

43
Q

is an unordered collection of unique elements

44
Q

are widely used for performing mathematical set operations such as union, intersection, and difference.

45
Q

common use cases for sets

A

eliminating duplicates
membership testing
finding common elements

46
Q

are a powerful data structure in Python that provide unique element storage and support efficient mathematical set operations.

47
Q

Python, known for its straightforward syntax and versatility, heavily relies on

A

functions.

48
Q

are defined blocks of code designed to perform a specific task.

A

Functions in Python

49
Q

vital roles of function

A

modularity
reusability
maintainability

50
Q

Variables specified in the function’s definition.

A

Formal Parameters:

51
Q

Values provided during the function call.

A

Actual Parameters:

52
Q

Functions can return data as a result.

A

Returning Values:

53
Q

If return is not used, the function returns None.

A

No Return Value:

54
Q

is used to exit a function and optionally pass an expression back to the caller.

A

The return statement in Python functions

55
Q

are essential for writing clean, organized, and efficient code. Understanding how to effectively define and use functions is key for any Python programmer.

A

Functions in Python

56
Q

Lists allow you to group related data elements of various types into a single entity. For example, you can use a list to store a sequence of integers, a list of strings, or a combination of different data types.

A

Grouping related data:

57
Q

Lists provide dynamic storage and retrieval of elements. Unlike arrays in some other programming languages, Python lists can grow or shrink in size as needed, making them flexible for handling varying amounts of data.

A

Dynamic storage and retrieval:

58
Q

Lists are commonly used in loops to iterate over the elements and perform operations on them. By accessing list elements sequentially, you can process large amounts of data efficiently.

A

Iteration and processing:

59
Q

Lists in Python can grow or shrink dynamically, allowing you to handle varying amounts of data without the need for explicit resizing.

A

Dynamic and flexible:

60
Q

Lists enable you to organize related data elements into a single sequence, making it easier to work with collections of data.

A

Data organization:

61
Q

Lists are commonly used in loops to iterate over elements and perform operations on them. They facilitate efficient data processing.

A

Iteration and processing:

62
Q

Lists can store elements of any data type, making them versatile for handling diverse types of data.

A

Versatility:

63
Q

Lists are a foundational concept used in many Python programs, scripts, and applications. Understanding lists is essential for becoming proficient in Python programming.

A

Widely used:

64
Q

involves creating a tuple by assigning values to it.

A

Tuple packing

65
Q

allows you to assign individual elements of a tuple to separate variables.

A

Tuple unpacking

66
Q

basic tuple operations

A
  1. concatenation
  2. repetition
  3. membership test
67
Q

Since tuples are immutable, they can be used as keys in dictionaries, ensuring data integrity and preventing accidental modification.

A

Data Integrity:

68
Q

Functions can return multiple values as a tuple, allowing convenient data packaging and unpacking.

A

Returning Multiple Values:

69
Q

The collections.namedtuple function creates named tuples, providing more readability and self-documenting code.

A

Named Tuples:

70
Q

Since sets only store unique elements, you can use them to remove duplicates from a list.

A

Eliminating Duplicates:

71
Q

Sets provide fast membership tests, making it efficient to check if an element exists in a collection.

A

Membership Testing:

72
Q

Set intersection can be used to find common elements between multiple sets.

A

Finding Common Elements: