My calc
Simple Python calculations
***** Task: The sum of two numbers Code: x = int(input()) y = int(input()) print(x+y)***** Task: Find the preceding and the next number Code: print("Please, enter the number") x = int(input()) print("The next number for", x, "is", x+1,".") print("The previous number for", x, "is", x-1,".")***** Task: Convert the number into a three-digit number. Code: def digits (): print("Please, enter three-digit number") x = int(input()) if (x<1000): print("*****") print("*",f'{x:03}',"*",sep='')#f'{x:03}' -add zeros. sep='' -remove spaces print("*****") print("Thank you!") else: print("Sorry, three-digits maximum") digits() digits()***** Task: Create table 3x3 from 9 numbers Code: a = int(input('First number?: ')) b = int(input('Second number?: ')) c = int(input('Third number?: ')) d = int(input('Forth number?: ')) e = int(input('Fifth number?: ')) f = int(input('Sixth number?: ')) g = int(input('Seventh number?: ')) h = int(input('Eighth number?: ')) i = int(input('Ninth number?: ')) print("|",f'{a:7}',"|",f'{b:7}',"|",f'{c:7}',"|",sep='') print("|",f'{d:7}',"|",f'{e:7}',"|",f'{f:7}',"|",sep='') print("|",f'{g:7}',"|",f'{h:7}',"|",f'{i:7}',"|",sep='')***** Task: Divide two numbers Code: K = int(input('K?: ')) N = int(input('N?: ')) print(int(K/N))***** Task: Calculate the number of the bags with vegetables. Code: while True: M = int(input('Potato(kg)?: ')) if M%20 == 0 and 0
2026-07-21 14:30:12
Comments
No comments yet. Be the first to leave one!
Leave a Comment