Can u plz help me make calculator with python language, thx | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can u plz help me make calculator with python language, thx

21st Jan 2021, 6:09 PM
Shogher Frangulyan
Shogher Frangulyan - avatar
7 Answers
+ 3
Shogher Frangulyan Start with 3 inputs: num1 num2 operator Then write a code which identifies the operator, and the actions that operator has on the 2 nums. You can do this with if, elif, else statements or by creating a dictionary. There are lots of examples posted on Sololearn
21st Jan 2021, 10:49 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Hats off to you Rik Wittkopp sir 😃
23rd Jan 2021, 8:06 AM
∆BH∆Y
∆BH∆Y - avatar
+ 2
Sir Rik Wittkopp I understood everything of your answer but how with a dictionary? After seeing it can be made with a dictionary I am confused😲 😕
23rd Jan 2021, 6:42 AM
∆BH∆Y
∆BH∆Y - avatar
+ 1
But how?
21st Jan 2021, 6:56 PM
Shogher Frangulyan
Shogher Frangulyan - avatar
+ 1
I will give an advice to start with: operation= input()#enter the full operation i.e 5+4, 89*7.. and then check if the plus operator "+" is in the operation, if it's the case, then use + elif check for / and * and so on ... it's easy just try with it! good luck !
21st Jan 2021, 10:44 PM
Hisham YUM 🇲🇦
Hisham YUM 🇲🇦 - avatar
23rd Jan 2021, 7:36 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
∆BH∆Y Thanks, but I learnt this technique from Sololearn, so the credit goes to the community. 🖐😁👍
23rd Jan 2021, 9:14 AM
Rik Wittkopp
Rik Wittkopp - avatar