Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
- def counting():
- counter = 0
- while counter < 10:
- print("Hello")
- counter += 1
- else:
- print("Bye!")
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- while True:
- if inp.lower() == 'y':
- counting()
- break
- elif inp.lower() == 'n':
- menu()
- break
- elif inp != str:
- print('not recognised')
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- def count2():
- li = ['Hello', 'Hello', 'Hello', 'Hello', 'Hello', 'Hello', 'Hello', 'Hello', 'Hello', 'Hello']
- for x in li:
- print (x)
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- while True:
- if inp.lower() == 'y':
- count2()
- break
- elif inp.lower() == 'n':
- menu()
- break
- elif inp != str:
- print('not recognised')
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- def even():
- for x in range(10, 20):
- even_ = []
- odd_ = []
- if x % 2 == 0:
- even_.append(x)
- else:
- odd_.append(x)
- return even_
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- while True:
- if inp.lower() == 'y':
- even()
- break
- elif inp.lower() == 'n':
- menu()
- break
- elif inp != str:
- print('not recognised')
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- def prime():
- print('')
- print('This is a function to give you all the pri'
- 'e numbers between two numbers you enter')
- print('Type in two numbers and you will get all the prime numbers between the two')
- print('')
- while True:
- try:
- x = int(input('Enter a number: '))
- y = int(input('Enter a last num: '))
- for z in range(x, y):
- p = []
- for n in range(1, z+1):
- if z % n == 0:
- p.append(n)
- if len(p) == 2:
- print(z)
- break
- except ValueError:
- print('Please enter a number')
- while True:
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- if inp.lower() == 'y':
- prime()
- break
- elif inp.lower() == 'n':
- menu()
- break
- elif inp != str:
- print('not recognised')
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- def pythag():
- while True:
- try:
- first = int(input('Enter a number: '))
- second = int(input('Enter another number: '))
- while True:
- if first != abs(first) or second != abs(second):
- print('Triangle sides cannot be negative')
- first = int(input('Enter a number: '))
- second = int(input('Enter another number: '))
- else:
- break
- c = first ** 2
- d = second ** 2
- e = c + d
- f = e ** 0.5
- print('The Pythagoras theorem calculation of your numbers is: ', f)
- break
- except ValueError:
- print('That s not a number, try again')
- while True:
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- if inp.lower() == 'y':
- pythag()
- break
- elif inp.lower() == 'n':
- menu()
- break
- elif inp != str:
- print('not recognised')
- inp = input('If you would like to repeat, press (y) otherwise press (n)')
- def menu():
- print('')
- print('A: Hello Counter')
- print('')
- print('B: Counter 2')
- print('')
- print('C: Find even numbers')
- print('')
- print('D: Prime Number')
- print('')
- print('E: Pythagoras Theorem')
- print('')
- ans = input('Choose a Function: ')
- while True:
- if ans.lower() == 'a':
- counting()
- break
- elif ans.lower() == 'b':
- count2()
- break
- elif ans.lower() == 'c':
- even()
- break
- elif ans.lower() == 'd':
- prime()
- break
- elif ans.lower() == 'e':
- pythag()
- else:
- print('Function not recognised. Please try again')
- ans = input('Choose a function: ')
- menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement