Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #program apa yg mau dibuat harus ada if dan loop:
- #1. membuat login
- #2. membuat existing account
- #3. terddapat dua menu login dgn existing account dan create new account
- #4. setelah login pilih menu ada tiga pilihan penjumlahan, pengurangan dan perkalian selain itu langsung exit
- # perlu beberapa perbaikan terutama di mekanisme jika pass dan username salah berkali kali (done dengan cara balik k menu utama)
- print("welcome to my first program")
- print('============================')
- def main_menu():
- print('choose menu: ')
- print('1. Create new account')
- print('2. login with existing account')
- print('choose 1 or 2 to input your choice: ')
- global menu
- menu = input()
- if menu == '1':
- make_account()
- else:
- login()
- def make_account():
- #create global variable
- global password
- global username
- print('input your username: ')
- username = input()
- print('input your password: ')
- password = input()
- if len(password) < 4:
- print('password must be at least 4 words please try again: ')
- password = input()
- print('account succesfully created')
- main_menu()
- else:
- main_menu()
- def login():
- print(username)
- print(password)
- print('what is your username: ')
- username_existing = input()
- print('what is your password: ')
- password_existing = input()
- if (password_existing != password):
- print('try again back to main menu')
- main_menu()
- else:
- print('sucess')
- main_program()
- def main_program():
- print('==============================')
- print('1. sum')
- print('2. multipication')
- print('3. sum more than 2 numbers')
- print('4. exit')
- print('choose menu: ')
- choice = input()
- if choice == '1':
- #calling sum menu
- sum()
- elif choice == '2':
- #calling multipication menu
- multipication()
- elif choice == '3':
- #calling sum_numbers function
- sum_number()
- else:
- #exit program
- print('thank you for trying my program !!!')
- def sum():
- print('input first number: ')
- first_number = int(input())
- print('input second number: ')
- second_number = int(input())
- result = first_number + second_number
- print('here is your result' +' '+ str(result))
- def multipication():
- print('input first number: ')
- first_number = int(input())
- print('input second number: ')
- second_number = int(input())
- result = first_number * second_number
- print('here is your multipication result' +' '+ str(result))
- def sum_number():
- # define list variable
- print('input your number and if u want to finish add 0')
- numbers = []
- while True:
- print('input ur numbers' + ' ' + str(len(numbers) + 1)+ ':')
- input_numbers = int(input())
- if input_numbers == 0:
- break
- numbers =numbers + [input_numbers]
- print('here is your numbers:')
- print(numbers)
- result = 0
- for input_numbers in numbers:
- result += input_numbers
- print(result)
- main_program()
- #calling first function to run main menu
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement