How to Build a Simple Calculator in Python - Step by Step 2
Пікірлер: 32
@saintlavrent Жыл бұрын
personally what I've done, this was a useful tutorial import math print("Select an operation to perform: ") print("1. ADD") print("2. SUBTRACT") print("3. MULTIPLY") print("4. DIVIDE") print("5. SQUARE ROOT") print("6. RAISE TO POWER") operation = input() if operation == "1": # performs addition num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The sum of this calculation is: " + str(int(num1) + int(num2))) elif operation == "2": # performs subtraction num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The sum of this calculation is: " + str(int(num1) - int(num2))) elif operation == "3": # performs multiplication num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The sum of this calculation is: " + str(int(num1) * int(num2))) elif operation == "4": # performs division num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The sum of this calculation is: " + str(int(num1) // int(num2))) elif operation == "5": # performs square root num = int(input("Enter number: ")) print("The square root is %f " %(float(math.sqrt(num))) ) elif operation == "6": # square a number num = int(input("Enter number: ")) print("The power is %d " %(pow(num, 2))) else: print("Invalid Entry")
@user-wx3mg3oh2y2 ай бұрын
Thank you man this is so good and useful
@user-ol7bq4ly1l3 жыл бұрын
Thank you sir
@towsifsadab10 ай бұрын
where’s the video of creating web interface and running this calculator into it?
@jingyin114910 ай бұрын
Good calculator
@Xidas_aventures8 ай бұрын
on raise to the power add second line of code asking "what would you like the power to be" and instead of the (num1, 2) you can do (num1, num2)
@divinepeace89242 жыл бұрын
I've inputed all but when I run my code, it's saying Type error: float is required
@beyondtemptationswithrida87878 ай бұрын
thankyouuuuuuuuuuuuu
@faizankhan-ev6it17 күн бұрын
Can any one tell me how to add the number in b/w the line like print(The square of NUM is %f"
@tondoewtw2 жыл бұрын
Full Calculator - import math print("Select an operation to perform: (1 - 6") print("1. ADD") print("2. SUBTRACT") print("3. MULTIPLY") print("4. DIVIDE") print("5. SQUARE ROOT") print("6. RAISE TO POWER") operation = input() if operation == "1": # PERFORM ADDITION num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The sum is " + str(int(num1) + int(num2))) elif operation == "2": # PERFORM SUBTRACTION num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The difference is " + str(int(num1) - int(num2))) elif operation == "3": # PERFORM MULTIPLICATION num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The product is " + str(int(num1) * int(num2))) elif operation == "4": # PERFORM DIVISION num1 = input("Enter first number: ") num2 = input("Enter second number: ") print("The result is " + str(int(num1) / int(num2))) elif operation == "5": # SQUARE ROOT num = int(input("Enter number: ")) print("The square root is %f " %(math.sqrt(num)) ) elif operation == "6": # RAISE TO POWER num = int(input("Enter number: ")) print("The power is %d " %(math.pow(num, 2)) ) else: print("Invalid Entry")
@divinepeace89242 жыл бұрын
Thanks. This helped a lot💯
@BennTresor-yj4mv Жыл бұрын
I have a small probleme in square root wnt i put "math" there are show me dat is undefined
@tondoewtw Жыл бұрын
@@BennTresor-yj4mv show me your code
@BennTresor-yj4mv Жыл бұрын
It thesame one you wrote
@memabe76293 жыл бұрын
Hi sir I need to develop a python program in anaconda to run an application like calculator or clock or any other applications if u have them in ur mind please suggest sir. Also how am I going to do it ?
@KindsonTheTechPro3 жыл бұрын
I'm working on this. Remember to subscribe so you can get notified when published
@memabe76293 жыл бұрын
@@KindsonTheTechPro is a quiz also an application?
@memabe76293 жыл бұрын
@@KindsonTheTechPro reply please
@KindsonTheTechPro3 жыл бұрын
@@memabe7629 yes, a quiz can be build as an application.
@zipzopebinay10 ай бұрын
@@KindsonTheTechPro sir , When will you uplode step 3 ??
@ragavaviraji4094Ай бұрын
Where is part three?? I guess he didn't upload it yet......even after 5 YEARS!!!!
@anondebennett92197 ай бұрын
Hy where is the follow up video to this one
@shaheersyed58182 жыл бұрын
How to repeat a f Program
@rikka7465 Жыл бұрын
So, if someone is looking for a code which raises x to the power of n while x and n are inputs from the user, here is it: elif operator == "6": # power of a number number_1 = input("What's your base number?: ") number_2 = input("What's your exponential number?: ") print("The sum is:" + str(float(number_1) ** float(number_2))) For me it didn't make sense to use pow( ) without a second number since it one, didn't work for me and two, I would like to user to choose their base and exponential number by themselves. Overall, good video thank you.