0% found this document useful (0 votes)
89 views

Python Programming Challenges

This document contains 7 programming challenges involving variables, selection, and loops in Python. The challenges include: 1) Asking for two friend's names and stating the best friend. 2) Asking for a favorite song and storing the lines in variables to output the full song. 3) Asking for coins in a piggy bank and calculating the total value. 4) Calculating discounts on purchases over or under £10. 5) Telling the user to save more if under £50 or they're doing well if over £50 based on their piggy bank savings. 6) Counting down from 10 and saying "Blast Off". 7) Simulating rolling a die and asking the user if they want to roll again
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views

Python Programming Challenges

This document contains 7 programming challenges involving variables, selection, and loops in Python. The challenges include: 1) Asking for two friend's names and stating the best friend. 2) Asking for a favorite song and storing the lines in variables to output the full song. 3) Asking for coins in a piggy bank and calculating the total value. 4) Calculating discounts on purchases over or under £10. 5) Telling the user to save more if under £50 or they're doing well if over £50 based on their piggy bank savings. 6) Counting down from 10 and saying "Blast Off". 7) Simulating rolling a die and asking the user if they want to roll again
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Programming Challenges –

Variables, Select, Loops – Python WS 5


1) Write a program that asks for 2 of your friend’s names and then states which friend is the
best friend.

2) Write a program that asks the user what their favourite song is and then asks them for line
1, line 2 and line 3. It should store the first, second and third lines of the song as variables
and then add the strings together to output the song.

3) Write a program that helps the user to add up the coins in their piggy bank. The program
should ask:

“How many pennies”, “How many two pences”, “How many 5 pences” etc. Then it should
give the total value of the piggy bank.

4) A shop is having a sale. They’re giving 10% off when a customer spends £10 or less and 20%
off when they spend over £10. Write a program that asks for the amount spent and then
displays the discount to be applied and then the final price (ie with the discount applied)

5) Using your Piggybank program from challenge 2.3; develop the program so that if the users
savings add up to less than £50 it tells them to save more and if it is over £50 it tells them
that they’re doing well.

6) Write a program that counts a blast off sequence for a space rocket, counting down from 10
and then saying ‘BLAST OFF’ . You will need to import time at the top of your code and use
time.sleep(secs).

7) Write a program that simulates (acts like) rolling a die. The program should ask the user if
they want to roll the dice, while they say yes it should tell them the number they have rolled
(“You have rolled a “). It should ask them again after each roll. If they say no, the program
should say ‘Goodbye’

Example of how to use random

import random
n = random.randint(1,6)
print (n)

You might also like