Programming Concepts and Loop Practice

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
GameKnowt Play
New
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

These flashcards cover programming concepts, sequence of operations, printing functions, and turtle graphics based on classroom problem-solving exercises.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

15 Terms

1
New cards

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.

2
New cards

What drawing is produced by the turtle code provided?

The code produces a shape with specific angles; sketch must include start and end points.

3
New cards

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}')

4
New cards

How many times is 'Hello' printed in the code: for i in range(2): print('Hello')?

'Hello' is printed 2 times.

5
New cards

How many times is 'Hello' printed in the code: for i in [2]: print('Hello')?

'Hello' is printed 1 time.

6
New cards

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).

7
New cards

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.')

8
New cards

What is printed with the code: print(list(range(3)))?

The output is [0, 1, 2].

9
New cards

What is printed with the code: print(list(range(-2, 3)))?

The output is [-2, -1, 0, 1, 2].

10
New cards

What is printed with the code: print(list(range(5, 0, -2)))?

The output is [5, 3, 1].

11
New cards

What is printed with the code: print(list(range(5, 0)))?

The output is [].

12
New cards

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.

13
New cards

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.

14
New cards

What is printed with the code: for i in ['hi', 'bye']: print(i)?

'hi' followed by 'bye' printed on separate lines.

15
New cards

What is printed with the code: for i in ['hi', 'bye']: print('i')?

'i' is printed twice, once for each iteration.