Understand how to input strings and numbers into variables: Difference between revisions
Mr. MacKenty (talk | contribs) |
Mr. MacKenty (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
This page is meant to be used in conjunction with [[media:Programming companion Python.pdf | our excellent resource for learning python]]. This page tracks with '''objective 2'''. | This page is meant to be used in conjunction with [[media:Programming companion Python.pdf | our excellent resource for learning python]]. This page tracks with '''objective 2'''. | ||
<br /> | |||
<br /> | |||
== Simple adder challenge == | == Simple adder challenge == |
Revision as of 10:06, 25 August 2021
![](/images/e/e4/Python.png)
This page is meant to be used in conjunction with our excellent resource for learning python. This page tracks with objective 2.
Simple adder challenge[edit]
Write a program that asks the user for two numbers. Part of the reason this one can be tricky is because you need to think about the Programming#Primitive data types of data you are using.
Click the expand link to see one possible solution, but NOT before you have tried and failed at least three times
number_1 = int(input("enter first number: "))
number_2 = int(input("enter second number: "))
answer = number_1 + number_2
print("The answer is ", str(answer))
Test marks challenge
Difficulty: G
Write a program that will ask the user to enter three test marks out of 100 and output the average.
Temperature converter challenge
Difficulty: G
Write a program to enter a temperature in degrees Fahrenheit and display the equivalent temperature in
degrees Centigrade.
The formula for conversion is Centigrade = (Fahrenheit – 32) * (5/9)
Height & weight challenge
Difficulty: G
Write a program to convert a person’s height in inches into centimetres and their weight in stones into
kilograms. [1 inch = 2.54 cm and 1 stone = 6.364 kg]
Toy cars challenge
Difficulty: G
A worker gets paid £9/hour plus £0.60 for every toy car they make in a factory. Write a program that
allows the worker to enter the number of hours they have worked and the number of trains they have
made. The program should output their wages for the day.
Fish tank volume challenge
Difficulty: G
Write a program that will ask the user to enter the length, depth and height of a fish tank in cm. Calculate
the volume of water required to fill the tank and display this volume in litres and UK gallons.
To calculate volume in litres, multiply length by depth by height and divide by 1000.
If you are still stuck, or you have other questions, you may want to ask a question on our discussion board.