1/14
These flashcards cover programming concepts, sequence of operations, printing functions, and turtle graphics based on classroom problem-solving exercises.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What value is printed when the following statements execute: print(17//3) and print(17 % 3)?
The first statement prints 5 and the second prints 2.
What drawing is produced by the turtle code provided?
The code produces a shape with specific angles; sketch must include start and end points.
How can you print 'I have a cat', 'I have a hamster', and 'I have a dog' using a for loop and the list myList=['cat', 'hamster', 'dog']?
for pet in myList: print(f'I have a {pet}')
How many times is 'Hello' printed in the code: for i in range(2): print('Hello')?
'Hello' is printed 2 times.
How many times is 'Hello' printed in the code: for i in [2]: print('Hello')?
'Hello' is printed 1 time.
Write a code that asks the user to enter an integer, adds 10 to it, and prints the result.
num = int(input()); print(num + 10) (no sentence needed).
How can I print 'There are 3 dogs and 5 cats.' using variables x=3 and y=5 without using the numbers directly?
print(f'There are {x} dogs and {y} cats.')
What is printed with the code: print(list(range(3)))?
The output is [0, 1, 2].
What is printed with the code: print(list(range(-2, 3)))?
The output is [-2, -1, 0, 1, 2].
What is printed with the code: print(list(range(5, 0, -2)))?
The output is [5, 3, 1].
What is printed with the code: print(list(range(5, 0)))?
The output is [].
What is printed after executing the following code: a=1; for i in range(1, 3): a = a + 2; b = 3 * i; print(i, a, b)?
The output for each iteration will show values of i, a and b.
What is printed after executing this code: x=3; for i in range(2): y = 3 + x; x = x - y; print(i, x, y)?
Final output shows the values of i, x, y after each iteration.
What is printed with the code: for i in ['hi', 'bye']: print(i)?
'hi' followed by 'bye' printed on separate lines.
What is printed with the code: for i in ['hi', 'bye']: print('i')?
'i' is printed twice, once for each iteration.