
It goes a little bit wonky in the teens ( "12nd"), but like I said, it isn’t a super straightforward problem, and I don’t want to sidetrack the review. This can be optimized using a dictionary acting as a case, but I think it’s fine as-is besides some minor duplication: def format_number( n: int) -> str: In their place, I’m going to use a simple function. Users will see the following message on their console application Select operation 1-Division, 2-Multiplication, 3-Addition, 4-Subtraction. For the sake of simplicity, I’m going to ignore the numeric words, because producing those is non-trivial and a whole project on its own unless you use an existing library. Loops would be the perfect tool here to reduce duplication although getting it exactly as you have will be difficult due to you currently spelling out numbers (“first”, “second”, “third”…). Print( "The calculator handles 5 numbers maximum!") V = float( input( "Enter the fifth number: ")) W = float( input( "Enter the forth number: "))
#Python console calculator software#
The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to support and facilitate the growth of a diverse and international community of Python programmers. Z = float( input( "Enter the third number: ")) The official home of the Python Programming Language. Y = float( input( "Enter the second number: "))įunc = int( input( '''What do you want to do?

X = float( input( "Enter the first number: ")) You can store your numbers in a list after taking them as input as a string separated by spaces, then splitting them into a list using the list.split() function and finally converting each of them to integers. # x = float(input("Enter the first number: ")) # y = float(input("Enter the second number: ")) # z = float(input("Enter the third number: ")) # w = float(input("Enter the forth number: ")) # v = float(input("Enter the fifth number: ")) if nums = 2:

Nums = int( input( "How many numbers you want to calculate?n")) I am new to python, I made a calculator but I need to make it calculating unlimited numbers and to shorten the code more, how can I improve it?
