Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. The aim of this program is to do simple and complex addition, subtraction, multiplication and division. Which is basically a calculator made using python.
  2.  
  3.  
  4. This program uses selection statement which is used to add, subtract, multiply and divide.
  5.  
  6. Comment in programming is readable explanation. In this program the first two lines use comment to tell us about the program what it is and what to do and comments usually use hash tags (#) in front of the text.
  7.  
  8. Variable are object in memory which have a given value. In this program we use lot of variables like add variable which helps you add two different number with the value given by a user. Subtract variable which helps you subtract one number from the other which also get value by the user. Multiply variable which is used to multiply two number and the value for this is also given by user. Division variable which divides one by another which also gets the value from the user.
  9.  
  10. Print statement is used to give message to a reader. In this case there is a lot of print statement like when you run the program it will display “your options are” and show the option of “1) addition”, “2) subtraction”, “3) multiplication”, “4) division” and “5) quit calculator.py”. At the end it uses more print statements such as “thankyou for using calculator!” and “goodbye”.
  11.  
  12.  
  13. If statement is a statement which is if proved true performs a function or can display information. In this program if statement is “ch == 1” so if the user presses 1 the if statement will be proven true and will start the process of addition.
  14.  
  15.  
  16.  
  17. What is the elif statement? How is it used in the program?Elif is used to add an extra condition which if proven true displays command. In this program there are 4 elif statement each has different function and if one is proven true it will do what the command says like if elif which is “ch == 2” is proven true it will start the process of subtraction.
  18.  
  19. Input statement allows you to enter information while the program is running. In this program the user uses input statement lot because from the start to the end you have to use input statement so that the program knows what the user wants it to do.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement