Save
Upgrade to remove ads
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

chapter 5 computer s

QuestionAnswer
Purpose of if statements: when you need to make decisions/choices in your program, allows you to execute the code only if the statement is true.
What is car=='bmw' A conditional statement
Always need An else statement
For Boolean you get True or false
== is what? Equality operator
!= is what? Inequality statment
For and they have to be? Both have to be TRUE
for or they have to be? Only ONE Of them has to be true.
What is the purpose of an elif statement? It allows you to check multiple conditions after an initial if. Only the first true elif block will execute.
What happens if none of the if or elif conditions are true and there is no else? The program simply skips the conditional block and continues with the rest of the code.
What is the difference between = and ==? = assigns a value to a variable, while == checks if two values are equal.
How can you combine multiple conditions in one if statement? Using logical operators like and, or, and not.
What does the not operator do in a conditional? It reverses the Boolean value (True becomes False, False becomes True).
True or False: The code inside an if block will always run. False. It only runs if the condition is True.
Can you write an if statement without elif or else? Yes. elif and else are optional.
What is short-circuit evaluation in Python? In and or or statements, Python stops evaluating as soon as the outcome is determined.
Which operator has higher precedence: and or or? and has higher precedence than or.
How do you check if a variable x is NOT equal to 10? Using x != 10.
What is a nested if statement? An if statement placed inside another if statement; allows checking multiple layers of conditions.
What is a nested if statement? An if inside another if
What will this code print? x = 8 if x > 5: if x < 10: print("x is between 6 and 9") x is between 6 and 9
Which of the following is falsy in Python? 0
if "": print("Hello") else: print("World") World
Which is a correct comparison chain for x > 5 and x < 15 5 < x < 15
in and not inWhat does the in operator do? Checks if a value exists in a sequence
How do you check if "banana" is NOT in a list ["apple", "orange", "grape"]? "banana" not in ["apple", "orange", "grape"]
How do you write this if-else as one line? if x > 0: message = "Positive" else: message = "Non-positive" message = "Positive" if x > 0 else "Non-positive"
What is wrong with this code? if x = 5 print("x is 5") = should be ==
Why will this code cause an error? print must be indented
Created by: Masterlearner5
 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards