Professional Documents
Culture Documents
Python Challenges Evidence
Python Challenges Evidence
Python Challenges Evidence
Python Challenge 1
Challenge 1
You will need to use:
Write a program that:
• asks the user to input their age Sequencing
• outputs 'Your age is: ' followed by their age
Variables
Difficulty:
© ZigZag Education, 2014
1
Python Challenge 1
1 point [x1]
The program asks the us
er to
input their age.
2 points [x1]
The age is outputted.
3 points [x1]
The output includes th
e text
‘Your age is: ’ plus the
age.
Difficulty:
© ZigZag Education, 2014
1
Python Challenge 2
1 point [x1]
The program asks the us
er to
input two numbers.
2 points [x1]
The average is calculat
ed and
outputted; however, it
may not
be correct.
3 points [x1]
The average is calculat
ed
correctly and outputted.
Tip: Multiply the width by the height to find the area of a rectangle.
Difficulty:
© ZigZag Education, 2014
1
Python Challenge 3
1 point [x1]
The program asks the us
er to
input the width and he
ight of a
rectangle.
2 points [x1]
The area is calculated
and
outputted; however, it
may not
be correct.
3 points [x1]
The area is calculated
correctly
and outputted.
Difficulty:
© ZigZag Education, 2014
1
Python Challenge 4
1 point [x1]
The program asks the us
er to
input two numbers.
2 points [x1]
The program divides th
e first
number by the second
number.
3 points [x1]
The result is outputted.
Difficulty:
© ZigZag Education, 2014
1
Python Challenge 5
1 point [x1]
The program asks the us
er for
their name and their fa
vourite
food.
2 points [x1]
The program asks the us
er for
their favourite food us
ing their
name in the question.
3 points [x1]
The program outputs a
sentence
that includes their favo
urite
food.
Difficulty:
© ZigZag Education, 2014
2
Python Challenge 6
1 point [x2]
The program asks the us
er to
input their name.
2 points [x2]
If the inputted name is
the same
as the programmer ’s na
me, the
program outputs ‘You’r
e cool’.
3 points [x2]
If the inputted name is
not the
same as the programm
er ’s
name, the program outp
uts
‘Nice to meet you’.
Difficulty:
© ZigZag Education, 2014
2
Python Challenge 7
1 point [x2]
The program asks the us
er how
long they spend on a co
mputer
per day.
2 points [x2]
If the response is less th
an 2, it
outputs ‘That seems
reasonable’.
3 points [x2]
If the response is less th
an 4, it
outputs ‘I’m surprised
you have
time for anything else!’
,
otherwise it outputs ‘Y
ou need
to get some fresh air on
ce in a
while’.
Difficulty:
© ZigZag Education, 2014
2
Python Challenge 8
1 point [x2]
The program asks the us
er to
input the student’s mar
k.
2 points [x2]
The program converts
most
marks to grades correc
tly.
3 points [x2]
The program converts
all marks
to grades correctly.
Difficulty:
© ZigZag Education, 2014
2
Python Challenge 9
1 point [x2]
The program asks the us
er to
input the name of one
of the
Olympic values.
2 points [x2]
The program outputs ‘T
hat’s
correct’ if they enter a
valid
Olympic value.
3 points [x2]
The program outputs ‘T
ry
again’ if they enter an
invalid
Olympic value.
Difficulty:
© ZigZag Education, 2014
2
Python Challenge 10
1 point [x2]
The program asks the us
er to
select rock, paper or sc
issors.
2 points [x2]
The outcome of the ga
me is
correctly calculated.
3 points [x2]
The computer’s answer
is
random.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 11
1 point [x3]
The program asks the us
er to
input a sentence.
2 points [x3]
The program outputs th
e
number of characters in
the
sentence.
3 points [x3]
The program outputs an
appropriate string alon
g with
the number of characte
rs in the
sentence.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 12
1 point [x3]
The program asks the us
er to
input a sentence.
2 points [x3]
The program outputs th
e
original sentence.
3 points [x3]
The program outputs th
e
sentence in upper case
.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 13
1 point [x3]
The program asks the us
er to
input a sentence and th
e word
they want to replace.
2 points [x3]
The program outputs th
e
original sentence.
3 points [x3]
The program outputs th
e
sentence with the word
replaced.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 14
1 point [x3]
The program asks the us
er to
input a sentence.
2 points [x3]
The program counts th
e number
of times ‘the’ occurs in
it.
3 points [x3]
The program outputs th
e
number of times ‘the’ oc
curs in
it.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 15
1 point [x3]
The program asks the us
er to
input a sentence.
2 points [x3]
The program outputs th
e
original sentence.
3 points [x3]
The program outputs th
e
sentence in lower case
.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 16
1 point [x3]
The program outputs so
me
numbers to the screen.
2 points [x3]
The program outputs th
e
numbers 1 to 10.
3 points [x3]
The program uses a Fo
r loop to
output the numbers 1 to
10.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 17
1 point [x3]
The program outputs so
me
numbers to the screen.
2 points [x3]
The program outputs so
me odd
numbers.
3 points [x3]
The program outputs al
l the odd
numbers from 1 to 99.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 18
1 point [x3]
The program asks the us
er to
input a number.
2 points [x3]
The program outputs th
e time
table for the inputted nu
mber.
3 points [x3]
The program includes
a For
loop to generate the tim
es table.
Tip: You must use a For Loop and a While Loop for this challenge.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 19
1 point [x3]
The program asks the us
er to
input a number.
2 points [x3]
The program outputs th
e times
table for the number gi
ven.
3 points [x3]
A While loop has been
used to
make the program repe
at
forever.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 20
1 point [x3]
The program asks the us
er to
guess the number.
2 points [x3]
If they input the numbe
r 7, the
program will output ‘W
ell
Done’.
3 points [x3]
The program loops until
the
user inputs the number
7.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 21
1 point [x3]
The program asks the us
er to
choose the type of the
conversion they want to
carry
out and to input the nu
mber
they want to convert.
2 points [x3]
The program correctly
converts
between inches and ce
ntimetres.
3 points [x3]
The program uses sepa
rate
functions to convert be
tween
inches and centimetres.
Difficulty:
© ZigZag Education, 2014
3
Python Challenge 22
1 point [x3]
The program asks the us
er to
input the distance and
time.
2 points [x3]
The program correctly
calculates the average
speed.
3 points [x3]
The program uses a fu
nction to
calculate the average sp
eed.
Difficulty:
© ZigZag Education, 2014
4
Python Challenge 23
1 point [x4]
The program asks the us
er to
input the dimensions of
the
lawn and the radius of
the
circle.
2 points [x4]
The program correctly
calculates the amount
of turf
required.
3 points [x4]
The program uses a fu
nction to
calculate the amount of
turf
required.
Difficulty:
© ZigZag Education, 2014
4
Python Challenge 24
1 point [x4]
The program displays
a number
of spaces followed by
a number
of Xs on the same line.
2 points [x4]
The program uses a fu
nction to
output a set number of
spaces
and Xs on the same lin
e.
3 points [x4]
The program uses anot
her
function to draw a pict
ure using
the first function.
• First Name
Selection
• Last Name
• Gender File Handling
• Form
Difficulty:
© ZigZag Education, 2014
4
Python Challenge 25
Challenge 25: Solution 1 point [x4]
#!/usr/bin/python3 The program asks the us
er to
input their First Name,
Last
print("----CLUB SIGN UP----") Name, Gender and Form
.
#User enters their details 2 points [x4]
first=input("Enter your first name: ") The data is stored in an
last=input("Enter your last name: ") external
text file.
gender=input("Enter your gender: ")
form=input("Enter your form: ")
3 points [x4]
#Opens the file or creates it if it doesn't already The data is stored with
exist appropriate labels in an
external
file = open("signup.txt", "a") text file.
#Records the user's details in the file
file.write("\nFirst name: "+first+", Last name:
"+last+", Gender: "+gender+", Form: "+form)
#Closes the file
file.close()
Difficulty:
© ZigZag Education, 2014
4
Python Challenge 26
1 point [x4]
The program asks the us
er to
input their name and th
en asks
three maths questions.
2 points [x4]
At the end of the questio
ns the
program displays the us
er ’s
name followed by thei
r score.
3 points [x4]
A function has been us
ed to
save the user ’s name an
d quiz
result to a text file.
Difficulty:
© ZigZag Education, 2014
5
Python Challenge 27
1 point [x5]
The program opens an
external
file.
2 points [x5]
The program loads the
scores
from an external file.
3 points [x5]
The program displays
the scores
from an external file.
1 point [x5]
The program opens an
external
file.
2 points [x5]
The program loads the
scores
from an external file.
3 points [x5]
The program displays
the scores
from an external file.
Difficulty:
© ZigZag Education, 2014
5
Python Challenge 28
1 point [x5]
The program asks the us
er to
input 5 names.
2 points [x5]
The program stores the
names
in an array.
3 points [x5]
The program outputs a
random
name from the array.
Difficulty:
© ZigZag Education, 2014
5
Python Challenge 29
1 point [x5]
The program asks the us
er for the
destination of their holid
ay, how
many things they need
to pack and
how many tasks they ne
ed to
complete.
2 points [x5]
The program should us
e a For loop
to ask the user to input
each item
they need to pack and ea
ch task
they need to complete.
3 points [x5]
The program should sto
re the
inputted data in an exte
rnal file in
a clear and easy-to-read
format.
2 points [x5]
The program should us
e a For loop
to ask the user to input
each item
they need to pack and ea
ch task
they need to complete.
3 points [x5]
The program should sto
re the
inputted data in an exte
rnal file in
a clear and easy-to-read
format.
Difficulty:
© ZigZag Education, 2014
5
Python Challenge 30
1 point [x5]
An attempt has been m
ade to
make a two-dimension
al array.
2 points [x5]
The program uses a tw
o-
dimensional array to st
ore the
questions and answers
for a
quiz.
3 points [x5]
A For loop is used to as
k the
questions stored in the
two-
dimensional array. At th
e end of
the quiz the user ’s scor
e must
be saved to an external
file.