You are on page 1of 2

 Asks the user how many sides a dice has

 Outputs a random number for that dice.


import random
user_number=int(input("Please enter neumber of sides "))
random_number=random.randint(1,user_number)
print(random_number,"is the random value")

 Aks the user for two numbers


 The program should output whether the two numbers are exactly divisible by each
other.
 If not, it should return the remainder.
 If the user enters a 0 the program should give an error message.
num_1=int(input("Please enter a number:"))
num_2=int(input("Please enter a number:"))
if num_2==0:
print("Error")
else:
remainder=num_1%num_2
if remainder==0:
print(num_1,"is exactly divisble by",num_2)
else:
print(num_1,"is not exactly divisible by",num_2, "there is a remainder of",remainder)
 Shows the user their balance of £231
 Asks them how much to withdraw
 Ensures this is a valid amount without going overdrawn and with the notes available
 Outputs the new balance.

balance=231
print(balance)
withdraw=int(input("Please enter desired amount to withdraw"))
if balance-withdraw<0:
print("you don't have sufdficient amount")
else:
if withdraw%20==0 and withdraw%10==0:
balance=balance-withdraw
print("new balance", balance)
else:
print("ony 10 and 20 notes")

Outputs all the squares of a number between 1 and 20

for counter in range(1,20):


answer=counter*counter
print(counter,"squared is",answer)

 Depending on the number entered for example if 4 was entered, the program outputs:
4 green bottles sitting on the wall
3 green bottles sitting on the wall
2 green bottles sitting on the wall
1 green bottles sitting on the wall
0 green bottles sitting on the wall

bottles=int(input("please enter number of bottles"))


for counter in range(bottles, -1, -1):
print(counter,"green bottles sitting on the wall")

You might also like