COMP PROG QUIZ (TERMINOLOGIES ONLY)

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

1/13

flashcard set

Earn XP

Description and Tags

study the concepts still !! CHATGPT !!

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

Python Loops

as they help you to execute a block of code repeatedly

You will often come face to face with situations where you would need to use a piece of code over and over but you don't want to write the same line of code multiple times.

2
New cards

while and for

2 Types of python loops?

3
New cards

while loop

is a programming concept that, when it's implemented, executes a piece of code over and over again while a given condition still holds true.

"interval" or a "period of time".

if you want to execute more than one statement inside one while loop, you must (as with if) indent all the instructions in the same way;

<p>is a programming concept that, when it's implemented, e<span style="color: rgb(255, 105, 105);">xecutes a piece of code over and over again while a given condition still holds true.</span></p><p><span style="color: rgb(255, 97, 97);">"interval" or a "period of time". </span></p><p>if you want to execute more than one statement inside one while loop, <span style="color: rgb(255, 96, 96);">you must (as with if) indent all the instructions in the same way;</span></p><p></p>
4
New cards

else statement

ends the loop naturally

<p>ends the loop naturally</p>
5
New cards

infinite loop

Indefinite iteration, the number of times the loop is executed isn’t specified explicitly in advance. Rather, the designated block is executed repeatedly as long as some condition is met.

<p><span style="color: rgb(255, 90, 90);">Indefinite iteration,</span><span style="color: rgb(255, 120, 120);"> the number of times the loop is executed isn’t specified explicitly in advance</span>. Rather, the designated block is executed repeatedly as long as some condition is met.</p>
6
New cards

break

is used to exit from the loop immediately after a particular condition is met.

<p>is <span style="color: rgb(255, 107, 107);">used to exit from the loop immediately after a particular condition is met.</span></p><p></p>
7
New cards

continue

skip some but still continue the loop, can still contain the else statement

<p>skip some <span style="color: rgb(126, 108, 255);">but still continue the loop</span>, <span style="color: rgb(255, 68, 68);">can still contain the else statement</span></p>
8
New cards

for loop

executes the code contained within it only for a specific number of times. This "number of times" is determined by a sequence or an ordered list of things.

when it's implemented, executes a piece of code over and over again "for" a certain number of times, based on a sequence.

<p> <span style="color: rgb(255, 105, 105);">executes the code contained within it only for a specific number of times. </span>This "number of times" is determined by a sequence or an ordered list of things.</p><p>when it's implemented,<span style="color: rgb(84, 123, 255);"> executes a piece of code over and over again "for" a certain number of times,</span> based on a sequence.</p><p></p>
9
New cards

Python Lists

are just like dynamically sized arrays, declared in other languages, a collection of things, enclosed in [ ] and separated by commas.

the simplest containers that are an integral part of the Python language. Lists need not be homogeneous always which makes it the most powerful tool in Python.

List items are indexed, the first item has index [0], the second item has index [1] etc.

List items are ordered, changeable, and allow duplicate values.

10
New cards

Use the index operator [ ]

to access an item in a list. The index must be an integer. Nested lists are accessed using nested indexing.

11
New cards

Negative Indexing

negative sequence indexes represent positions from the end of the List. Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second-last item, etc.

12
New cards

len()

list's name as an argument, and returns the number of elements currently stored inside the list (in other words ‒ the list's length).

<p>list's name as an argument, and returns the number of elements currently stored inside the list <span style="color: rgb(255, 98, 98);">(in other words ‒ the list's length).</span></p><p></p>
13
New cards

append()

Elements can be added to the List by using the built-in ___ function. Only one element at a time can be added to the list by using the append() method, for the addition of multiple elements with the append() method, loops are used.

<p><span style="color: rgb(255, 84, 84);">Elements can be added to the List by using the built-in ___ function.</span> Only one element at a time can be added to the list by using the append() method, for the addition of multiple elements with the append() method, loops are used. </p><p></p>
14
New cards

insert()

method requires two arguments (position, value).

<p> method <span style="color: rgb(255, 109, 109);">requires two arguments (position, value). </span></p>