hello quizlet
Home
Subjects
Expert solutions
Create
Study sets, textbooks, questions
Log in
Sign up
Upgrade to remove ads
Only $35.99/year
TechSmart Lesson 2.1 & 2.1 - 2.4 Vocabulary
Flashcards
Learn
Test
Match
Flashcards
Learn
Test
Match
Lesson 2.1 & Unit 2.1 - 2.4 Vocabulary
Terms in this set (33)
Conditional
decides whether to skip a section of code
Ex. If it's raining then bring an umbrella
If clause
Starts a conditional
ex. If it's raining
Condition
Asks a yes or no question
Ex. Is it raining?
Comparison operator
Compares two values; gives a yes or no answer
Ex. < Less than
> Greater than
<= Lesser or equal to
>= Greater or equal to
== Is equal to
!= Not equal
Then-block
Code that might be skipped
Elif clause
Checks another condition
Ex. Elif condition:
then-block code
Else
Runs if nothing else was True
Ex. Else:
Else-block code
boolean
A data type with two possible values: True or False
Ex. playing == True
boolean expression
An expression that creates a boolean value
Ex. num > 0
# if num is 5 the value is True
# if num is -5, the value is False
logical operator
combine or modify boolean values
Ex. and, or and not
and
A logical operator that makes an expression True only if all parts are True
Ex. True and True ----> True
True and False ---> False
or
A logical operator that makes an expression True as long as one part is True
Ex.
True or True -----> True
True or False ----> True
False or False ---> False
not
A logical operator that turns an boolean value to it's opposite value.
Ex.
player1_turn = not player1_turn
---> turns player1_turn from True to False or from False to True
nesting
Structures inside of other structures
Ex. a conditional in the then-block of another conditional
if x:
if y:
print("x and y are both True")
while loop
repeats a section of code as long as it's condition is true
Ex. while running:
print("keep going")
while clause
Starts a while loop
Ex. while x < 10:
loop block
code that gets repeated
Ex. print(x)
x += 1
break statement
immediately stops a loop by skipping to the end of the loop-block and not running another iteration
Ex. while True:
break
In the following code, identify the conditionals that includes the elif-clause.
if x == 1:
print("x is 1")
if y == 2:
print("y is 2")
elif x == w:
print("x is w")
elif x == 5:
print("X is 5")
if x < 53:
print("x is less than 53")
if y == 2:
print("y is 2")
elif x == w:
print("X is w")
elif x == 5:
print("X is 5")
Remember that a conditional starts with an if-clause. Any new if-clause starts an entirely new conditional. Elif-clauses belong to the if-clause that comes before them.
Which of the following is not a type of conditional clause?if, elif, then, or else
then
How many times will the following code print the statement "Print me"?
x = 0
while x < 1000:
print("Print me")
x += 100
10
This code starts at 0, counts by 100 each loop, and ends just before 1000. So x will have each of the following values: 0, 100, 200, 300, 400, 500, 600, 700, 800, 900.
Identify the condition in the following code.
if x < y:
print("x is smaller")
print("y is bigger")
x y
Identify the if-clause in the following code.
if x < y:
print("x is smaller")
print("y is bigger")
if x < y:
What happens if the condition in a conditional is False?
The program skips the then-block
In the following code, the then-block will never execute. Why?
if 100 < 10:
print("We executed!")
print("Congratulations!")
print("The program finished.")
The condition will always be false.
Add a symbol to the conditional so it is formatted correctly.
x = 10
y = 5
if x > y
print("x is bigger than y")
add a colon after if x > y. Should be written if x > y:
In the following code, identify the print statement that will never be printed.
if x > y:
print("Case 1")
if x < y:
print("Case 2")
if x == y:
print("Case 3")
else:
print("Case 4")
print("Case 4")
What is the maximum number of elif clauses you can have in a conditional?
Unlimited
What is the maximum number of else clauses you can have in a conditional?
1
Identify all the clauses in the conditional below.
if money > 100:
print("Wow!")
elif money > 50:
print("Not bad!")
elif money > 10:
print("You got something!")
else:
print("You need some cash!")
if money > 100:
elif money > 50:
elif money > 10:
else:
Identify the error in the following conditional.
if x > 100
print("x is greater than 100")
if x > 100:
print("x is greater than 100")
Why will the code below cause an error?
if x == 100:
print("100")
elif:
print("x is not 100")
elif must have a condition
What is the fewest lines that can be in a then-block?
1
Other sets by this creator
TechSmart Python Unit 2; 2.1 - 2.3 ONLY
40 terms
Brain Functions Review
16 terms
PLTW-Medical Detectives: Lesson 1
29 terms
TechSmart Lesson 1 Vocabulary
28 terms
Verified questions
vocabulary
Underline all the pronouns in each of the following sentences. **Example 1**. This weekend Beth and Bryan painted $\underline{\text{several}}$ of the rooms in $\underline{\text{their}}$ house. “You can stir the paint while I put drop cloths over the furniture.”
literature
Read each personality description and then choose the word from the list provided that identifies it. Use a dictionary to define the terms if you need to. melancholic phlegmatic sanguine choleric The only movies Mr. Ioacca wants to watch are those with unhappy endings.
question
Many periods and all exclamation points and question marks have been omitted from the following passage. Write each word that should be followed by an end mark, add the appropriate end mark, and as needed, capitalize the first word of the sentence following the end mark. For any quotation requiring an end mark, include the closing quotation marks to show the proper placement of the end mark. EXAMPLES :[1] Dr. Lynn Block, director of research for the Larson Soap Company, looked at her appointment book 1. book. [2] "oh, no" she groaned 2. "Oh, no!"; groaned. *Oh. dear," thought Dr. Block as she surveyed the young man's torn jeans, unironed T-shirt, and shaggy hair
literature
Write short informative articles about two of the creatures Odysseus and his crew encounter. Begin with a definition, and then provide additional information from the Odyssey and from your own imagination. Place your reports in your Working Portfolio.
Other Quizlet sets
Micro Exam 4 Chapter 15
87 terms
CsT02 anatomy and physiology chat 2 study guide
50 terms
Fin 3720 Exam 1 - Essay
10 terms
Florida Legal Guidelines Sample Questions
102 terms