Branches and Loops

¡Supera tus tareas y exámenes ahora con Quizwiz!

While loop

A condition-controlled loop that is used for repeating the loop body until the condition is false. The condition is tested before entering the loop and each subsequent iteration.

if statement

A conditional statement. IF something is true then 'sequence A' will run. IF is it is not 'sequence B' will run. (allows selection to happen)

Branch

A program path that is only tkae if a condition is true

Loop

A sequence of instructions that will continually repeat

range() function

Allows iteration of a block of code a specific number of times. The function will always start at zero by default, incrementing by 1 by default, and ends at the specified number subtracted by 1.

If-Elif statement

Allows the checking of multiple conditions

If-else statement

Control structure that lets us do either one section of code or another depending on a test.

break statement

Ends execution of the loop inside of it

continue statement

Skips the rest of the current iteration to continue the loop.

For loop

Used for when the exact number of iterations is known. This loop iterates items of a sequence, such as a string or list. Range function can also be used to iterate a number a specific amount of times.

Python branch keywords

and, or, not, is

Types of Python branches

if, else, and elif

Two types of Python loops

while and for


Conjuntos de estudio relacionados

focus on: understanding your sexuality

View Set

MedSurg 2 Exam 1 Study Set (ABG)

View Set

CNA - Basic Nursing Skills (Unit 2)

View Set

Bullying and Violence in the Workplace

View Set

Unit 5 (chapter 21) History of Graphic Design

View Set