Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
20 Cards in this Set
- Front
- Back
Write a Python statementthat evaluates to True if the variable whose name is num hasa value greater than 0 and less than 10. |
num > 0 and num < 10 |
|
Write a Python statement that evaluates to True if the variable whose name is num has a value greater than or equal to 0 and less than or equal to 10. |
num >= 0 and num <= 10 |
|
What is the data type of the variable whose name is value_good that is created by the following statement? value_good = num > 0 |
boolean |
|
In the loop below, what happens each time the condition the boolean expression after the keyword while evaluates to true? while num < 10: num = num + 1 |
the value of num increases by 1 |
|
If the value of the variable num is 0 before entering the loop above, how many times does the indented statement run? |
10 |
|
If the value of the variable num is 0 before entering the loop above, what is the value of the variable num after the loop stops running? |
10 |
|
When does a while loop stop? |
when the boolean expression after the keyword while becomes false |
|
How does the Python interpreter know the difference between the statement in the loop and the statements after the loop? |
the statements after the loop are not indented |
|
If you wanted to check that the number entered by a user was greater than 0, and you wanted to keep prompting the user until they entered a correct value, what kind of control structure would you use? |
a while loop |
|
How would you stop a script that is in an infinite loop? |
Control C |
|
Whatfollows the keyword in in a Python for loop? |
a list of values |
|
What is the name of the Python function used to create a list of numbers in a for loop? |
range |
|
If the function mentioned above were run with the single argument 5, what is the list of numbers that would be created? |
0, 1, 2, 3, 4 |
|
If the function mentioned above were run with the two arguments 1 and 5, what is the list of numbers that would be created? |
1, 2, 3, 4 |
|
If the function mentioned above were run with the three arguments 1, 10 and 2, what is the list of numbers that would be created? |
1, 3, 5, 7, 9 |
|
If the function above is run with only one argument, what does that argument specify? |
one more than the last number in the list |
|
If the function above is run with two arguments, what does the first of the two arguments specify? |
the first number in the list |
|
If the function above is run with three arguments, what does the third of the three arguments specify? |
the difference between each number in the list |
|
Write a for loop that prints the values from 1 to 10, each on a separate line. |
for number in range(10): print(number + 1) |
|
Write a for loop that prints the values from 10 to 1, each on a separate line. |
for number in range(10, 0, -1): print(number)
|