oop Flashcards
(72 cards)
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
while loop
is a little different from while sense that it work more like an iterative procedure and for keyword
for Loop
is an iterative sequence that works on List, string dictionaries, tuples, set array, and Etc.
for Loop
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
for loop with strings
the inner loop will be executed each iteration if the value of outer loop is true
nested loop
sometimes ———- used in multi-dimensional array or depends on the problem outcome you want to have
nested looping
Stops the code immedietly when its met or encountered
break statement
It skips the current iteration and proceed to the next iteration
continue statement
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
list
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
lists
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
ordered
are immutable sequences in Python that is once created elements cannot be changed added to or removed from it
tuples
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
tuples
A —- in Python is an unordered collection of unique elements.
set
are defined using curly brace or by calling the set function
Sets
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
set
characteristics of a sets
- unordered
- mutable
- no duplicates
- heterogenous
is a fundamental iterative structure in Python programming that allows you to repeat a code block as long as a specified condition is true.
The while loop
is a fundamental construct in Python programming that enables you to repeat a code block as long as a specified condition remains true.
The while loop
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.)
The for loop
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.
item
can be any iterable object, such as a list, tuple, string, or range, that contains multiple elements
The sequence
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.
The for loop
In Python, just like in C, it is possible to use loops within loops, which is known as
nested loops