Search Header Logo
Python Programming Homework 1

Python Programming Homework 1

Assessment

Presentation

Computers

6th - 9th Grade

Medium

Created by

Kevin Moore

Used 268+ times

FREE Resource

3 Slides • 13 Questions

1

Python Programming Homework 1

2

​What is a variable?

​You may have encountered the word 'variable' in Science or Maths.

​In programming a variable is a container for storing data (in memory) - the data stored can be changed whilst the program is running.

​We can assign values to variables directly or we can get data from user input

media

3

Multiple Choice

Which of the following is an example of a variable in Python?

1

print("hello")

2

age=13

3

input("Enter your age")

4

type()

4

Fill in the Blank

The contents of a variable can be changed while the _______ is running

5

Multiple Choice

a = 10

b=5

b=a+5

print(b)

What would be printed to the screen in this example?

1

5

2

10

3

105

4

15

6

Multiple Choice

a = 10

b=5

b=a+5

print(a)

What would be printed to the screen in this example?

1

5

2

10

3

105

4

15

7

Multiple Choice

a = 10

b=5

b=a+5

print(a+b)

What would be printed to the screen in this example?

1

5

2

10

3

25

4

15

8

​What is iteration?

In lesson 2 we looked at count-controlled loops (FOR loops). loops are also known as Iteration.

​A For loop allows us to repeat an instruction a set number of times.

Remember the Happy Birthday program you wrote in the lesson? You used a for loop to control the output of the song - it also saved you having to repeat lines of code.

media

9

Multiple Choice

FOR loops are

1

loops which run an unknown number of times

2

loops which run for a specific number of times

3

the same as if statements

4

not part of programming

10

Multiple Choice

This loop can only be used when the programmer knows the number of times a code is to be repeated

1

while

2

for

3

do while

4

repeat until

11

Multiple Choice

Which kind of loop would be used?

I need a revision program that will run through revision questions 4 times.

1

FOR Loop

2

WHILE Loop

12

Multiple Choice

In programming, what is iteration?

1

The repetition of steps within a program

2

The order in which instructions are carried out

3

A decision point in a program

4

Testing a program to make sure it works

13

Multiple Choice

Why is iteration important?

1

It determines the order in which instructions are carried out

2

It allows code to be simplified by removing duplicated steps

3

It allows multiple paths through a program

4

It ensures the code works correctly

14

Multiple Choice

Question image

Look at the following code, what will it generate

1

1,2,3,4,5,6,7,8,9,10,11,12

2

0,1,2,3,4,5,6,7,8,9,10,11,12

3

1,2,3,4,5,6,7,8,9,10,11,12,13

4

0,1,2,3,4,5,6,7,8,9,10,11,12,13

15

Multiple Choice

Question image

What does the following program display?

1

1,2,3,4

2

1,2,3,4,5

3

counter,counter,counter,counter,counter

4

0,1,2,3,4,5

16

Multiple Choice

Question image

What does the program display as its output?

1
2
3
4

1,2,3,4

Python Programming Homework 1

Show answer

Auto Play

Slide 1 / 16

SLIDE