IT101-1L midterms lesson 8-12 Flashcards

1
Q

allow you to make decisions and execute different code blocks based on certain conditions.

A

selection structures

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

allows you to execute a block of code only if a specified condition is True.

A

if statement

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

extends the if statement by providing an alternative code block to be executed when the condition is False

A

if-else statement

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

t allows you to evaluate multiple conditions in a sequential manner. It is used when you have more than two possible outcomes

A

if-elif-else statement

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

are used in programming to compare values and determine the relationship between them.

A

Relational operators

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

is used within loops (such as for or while) to exit the loop immediately.

A

break statement

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

Checks if two values are equal.

A

== (equal to):

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

Checks if two values are not equal.

A

!= (not equal to):

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

> (greater than): Checks if the left operand is greater than the right operand.

A

> (greater than):

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

Checks if the left operand is less than the right operand.

A

< (less than):

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

Checks if the left operand is greater than or equal to the right operand.

A

> = (greater than or equal to):

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

Checks if the left operand is less than or equal to the right operand.

A

<= (less than or equal to):

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

The and operator returns True if both of its operands are True, and False otherwise.

A

and:

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

The or operator returns True if at least one of its operands is True, and False otherwise.

A

or:

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

: The not operator reverses the logical state of its operand. If the operand is True, the not operator returns False, and if the operand is False, it returns True.

A

not

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

means that the second operand of an and or or operator is not evaluated if the outcome can be determined solely by evaluating the first operand.

A

Short-circuit evaluation

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

you can control the flow of your program and stop the loop execution based on certain conditions.

A

break statement,

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

is an expression that evaluates to either True or False.

A

condition

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

The _________ statement can be extended to include multiple conditions using the _____

A

if…else, elif

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

By using _________, you can create decision trees with multiple branches, allowing your program to respond differently based on different conditions.

A

multiple elif clauses

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

refer to the practice of placing one or more if…else statements inside another if or else block.

A

Nested decisions

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

, are fundamental programming constructs that allow you to repeat a code block multiple times based on specified conditions.

A

Iterative structures, commonly known as loops

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

evaluates the condition before executing the code block.

A

The while loop

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

in Python is used to iterate over elements of an iterable

A

The for loop

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

They allow you to repeat code blocks based on conditions, which helps automate repetitive tasks and control program flow

A

Loops (Iterative structures)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
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

while loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
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

A

for loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
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
29
Q

Nested loops are essential in programming as they allow you to work with complex data structures and perform operations on multiple dimensions

A

Nested loops

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

is used to prematurely terminate the execution of a loop

A

break statement

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

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

A

continue

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

is used within loops (such as for or while) to skip the remaining statements within the loop’s code block and move to the next iteration

A

The continue statement

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

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

A

list

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

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

A

Lists

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

: Lists allow you to group related data elements of various types into a single entity.

A

Grouping related data

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

To create a list in Python, you can simply use

A

square brackets []

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

returns the number of elements present in a list

A

len() function

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

allows you to add an element to the end of the list. It modifies the original list in place.

A

append() function

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

adds elements from another list to the end of the current list. It extends the list in place.

A

extend() function

40
Q

allows you to insert an element at a specific index in the list

A

insert() function

41
Q

is used to remove the first occurrence of a specified element from the list.

A

remove() function

42
Q

is used to remove and return the element at a specific index.

A

pop() function

43
Q

removes all elements from the list, making it an empty list.

A

clear() function

44
Q

returns the index of the first occurrence of a specified element in the list.

A

index() function

45
Q

returns the number of occurrences of a specified element in the list.

A

count() function

46
Q

is used to sort the list in ascending order. It modifies the original list in place.

A

sort() function

47
Q

reverses the order of elements in the list. It modifies the original list in place.

A

reverse() function

48
Q

creates a shallow copy of the list.

A

copy() function

49
Q

The new list that will be created using list comprehension.

A

new_list:

50
Q

applied to each item in the iterable to create elements of the new list.

A

expression:

51
Q

The variable representing each element in the iterable.

A

item:

52
Q

: The source data from which the list will be generated.

A

iterable

53
Q

A conditional expression that filters elements based on certain criteria

A

condition: (Optional)

54
Q

with list comprehension to apply a function to each element

A

Use map()

55
Q

with list comprehension to include only certain elements

A

Use filter()

56
Q

is an ordered collection of elements enclosed in parentheses ( ).

A

tuple

57
Q

can be used to create a tuple from an iterable object like a list or a string

A

tuple() constructor

58
Q

The values are assigned to the tuple using a single assignment statement.

A

Tuple packing

59
Q

allows you to assign the elements of a tuple to individual variables in a single assignment statemen

A

Tuple unpacking

60
Q

Tuples can be ______ using the + operator.

A

concatenated

61
Q

A tuple can be repeated using the * operator.

A

Repetition

62
Q

You can check if an element exists in a tuple using the in keyword.

A

Membership test

63
Q

Tuples are _______, meaning their elements cannot be changed after creation.

A

immutable

64
Q

is an unordered collection of unique elements.

A

set

65
Q

can be created and initialized using curly braces { } or the set() constructor.

A

Sets

66
Q

add elements to a set using the

A

add() method

67
Q

to add multiple elements.

A

update() method

68
Q

Removes an element from a set

A

remove()

69
Q

removes element and even if element not there its not an error

A

discard()

70
Q

Removes and returns an arbitrary element somewhere else

A

pop()

71
Q

puts all elements together in a set

A

Union

72
Q

returns teh same elements between 2 sets

A

intersection

73
Q

Dividing the program into separate parts for better organization and management.

A

Modularity:

74
Q

: Allowing the same code to be used in different scenarios, reducing redundancy.

A

Reusability

75
Q

Making the codebase easier to understand and modify.

A

Maintainability:

76
Q

is defined using the def keyword, followed by the function name, parentheses with any parameters, and a colon.

A

function

77
Q

Variables specified in the function’s definition.

A

Formal Parameters:

78
Q

Values provided during the function call.

A

Actual Parameters:

79
Q

statement in Python functions is used to exit a function and optionally pass an expression back to the caller.

A

return

80
Q

Functions can return data as a result.

A

Returning Values:

81
Q

: If return is not used, the function returns None.

A

No Return Value

82
Q

The keyword used to define a function in Python.

A

def:

83
Q

A unique name for the function, following the Python identifier naming rules.

A

function_name:

84
Q

: The list of input parameters (if any) that the function expects. If there are no parameters, leave the parentheses empty.

A

parameter_list

85
Q

The block of code inside the function where the task is performed.

A

function body:

86
Q

If the function has a return value, it can be specified using the return statement. If there is no return statement, the function returns None by default.

A

return value:

87
Q

, are the values that are passed to a function when it is called.

A

Actual parameters, also known as arguments

88
Q

, are placeholders defined in the function declaration or definition

A

Formal parameters, also referred to as parameters or function parameters

89
Q

all parameters are passed by

A

object reference

90
Q

is an essential aspect of programming that allows you to interact with files on your computer’s file system.

A

File handling

91
Q

To create a new file, you can use the ________ with the appropriate file mode

A

open() function

92
Q

read data from a file, you can use the open() function and file methods such as

A

read(), readline(), or readlines()

93
Q

To update the contents of a file, you can use the open() function and file methods such as

A

write() or append().

94
Q

function is called with the name of the file to be deleted.

A

os.remove()

95
Q

What does CRUD MEAN?

A

Creating, Reading, Updating, and Deleting Files

96
Q

What does csv mean?

A

Comma-Separated Values

97
Q
A