Computer science Conditionals

0.0(0)
Studied by 4 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:20 PM on 10/27/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

21 Terms

1
New cards

Boolean

A value which is true or false; it is a variable type.

2
New cards

What does type(True) return?

bool (indicating Boolean type).

3
New cards

What is str(True) used for?

To convert a Boolean to a true value type (string).

4
New cards

What is an if statement?

Runs a program on specific conditions.

5
New cards

What is the syntax of an if statement?

if (condition): # code block else: # code block

6
New cards

What should I know about the if branch?

Prints something if the condition is met and must evaluate to a Boolean (True or False).

7
New cards

What should I know about the elif branch?

It has a condition and only runs if the first if condition is not met.

8
New cards

What should I know about the else branch?

Executes the program if the condition in if and elif is not met; no specific condition is required.

9
New cards

What are the comparison operators in Python?

== : equal to; != : not equal to; < : less than; > : greater than; <= : less than or equal to; >= : greater than or equal to.
10
New cards

How do you check if more than one condition is true?

Use and or or.

11
New cards

What is the order of the alphabet when comparing strings?

Symbols/numbers, Uppercase letters, Lowercase letters.

12
New cards

How do you compare strings in Python?

== : equal to; != : not equal to; < : earlier in dictionary order; > : later in dictionary order.

13
New cards

Given x = 5, what is the result of x < 10?

True.

14
New cards

What are the logical operators in Python?

not : Changes a true value to false; and : True if both conditions are true; or : True if at least one condition is true.

15
New cards

What is a truth table?

Shows values of Boolean expressions given x and y; used to analyze logic in expressions.

16
New cards

What is a Venn Diagram used for in logical operators?

Visually shows logical operators.

17
New cards

Why do we use the round command?

Because Python sometimes rounds very weirdly; it’s used to round a number to a specific decimal value.

18
New cards

What does round(value, decimals) do?

Rounds a number to a given number of decimal places.

19
New cards

What is float in Python?

Changes an element to a float type (decimal).

20
New cards

How do you generate a random number?

Use randint inside of a random function; imports the random library.

21
New cards

What is a package in Python?

Organizes related modules into a hierarchical structure.