Nuestro grupo de expertos pasados algunos días de investigación y de recopilar de información, obtuvieron la solución, nuestro deseo es que te sea de gran utilidad en tu proyecto.
Ejemplo 1: calculadora de Python simple
#Store number variables for the two numbers
num1 =input('Enter first number: ')
num2 =input('Enter second number: ')#the sum of the two numbers variablesum=float(num1)+float(num2)
sum2 =float(num1)-float(num2)
sum3 =float(num1)*float(num2)
sum4 =float(num1)/float(num2)#what operator to use
choice =input('Enter an operator, + = addition, - = subtraction, * = multiplication and / = division: ')#different sums based on the operatorsif choice =='+':print('The sum of 0 and 1 is 2'.format(num1, num2,sum))if choice =='-':print('The sum of 0 and 1 is 2'.format(num1, num2, sum2))if choice =='*':print('The sum of 0 and 1 is 2'.format(num1, num2, sum3))if choice =='/':print('The sum of 0 and 1 is 2'.format(num1, num2, sum4))
Ejemplo 2: calculadora simple en python
#Simple Calculator Program in Python by Rupesh Singhdefsum1(first_input, second_input):# Sum function "+"
result1 = first_input + second_input
print("Your Answer is:-", result1)returndefminus(first_input, second_input):# Minus function "-"
result2 = first_input - second_input
print("Your Answer is:-", result2)returndefmulti(first_input, second_input):# Multiplication function "*"
result3 = first_input * second_input
print("Your Answer is:-", result3)returndefdiv(first_input, second_input):# Division function "/"
result4 = first_input / second_input
result4 =float(round(result4))print("Your Answer is:-", result4)return# User Input
first_input =int(input("Enter your 1st Input:- "))
command =input("What you want to do (+, -, *, /):- ")
second_input =int(input("enter your 2nd Input:- "))if command =="+":
sum1(first_input, second_input)elif command =="-":
minus(first_input, second_input)elif command =="*":
multi(first_input, second_input)elif command =="/":
div(first_input, second_input)else:print("Command Error!")
valoraciones y comentarios
Agradecemos que desees corroborar nuestra publicación poniendo un comentario y dejando una valoración te estamos eternamente agradecidos.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)