In this section you can find tasks based on if statements.
Printers are fickle devices at the best of times. In order to work out if a printer is going to print or not depends on the printer being in the following state. Depending on the state the printer should output one of the following (and ONLY one) Out of paper – please insert more paper […]
A coin toss can be simulated by using a random number. A 1 represents heads and 0 represents tails. It can be done using the following code. import random coin = random.randint(0,1) You need to write a if statement which will keep count of the number of times heads or tails are thrown. Also add […]
Jeepers, this recession is hurting my wallet. I better write a program to see if I can afford some items. Start off with this code – c = [1.99, 5.99, 4.50, 12.43, 99.99] d = ["cookies", "cake", "chocolates", "posh chocs", "very posh chocs"] a = 0 cash = 5.00 while a < len(c): print "Item […]
Your in high stake negotiation with Bob. The pressure is on to get the product you need for the best price possible. The starting price is £100k. You happen to know that Bob is very predictable when negotiating. When you make an offer Bob will to one of the following. He will walk away if […]
Using a set of IF statements you need to write a simple python program which will work out your grade on a F452 exam. The grade boundaries are – A – 81+ B – 75 C – 69 D – 63 E – 58 U – <=57 The program must allow the user to enter […]
You must write a program which decides if a given year is a leap year or not. Sounds hard but there is a very simple algorithim you can use! Just implement the following rules in code. You must implement them in order and not run the other rules once one has been matched. It is […]
Write a program which will ask the user if they want to convert kilograms to ounces or visa versa. Then get the user to enter then number and output the result. Give the user the option to repeat the conversion. You need to log in or create an account to submit code!
A lot of people, after a shopping trip, will put their loose change into a jar. Over time, this jar can have a lot of money! Your task is to create a program which will calculate how much money you have in a jar. A sample run could look like – Enter the number of […]
Argos have a special offer where you can get vouchers to spend in store if you spend a certain amount of money. Spend £50 – get a £5 voucher Spend £100 – get a £12 voucher Spend £200 – get a £25 voucher For every £100 over £200, you get another £10 voucher. Example – […]