Skip to main content

Posts

Showing posts with the label Python programming

Tutorial 4:Arithmetic Operators in Pythons

Revision In previous tutorial, we've known that  5  is an integer and  "5"  is string. 5   and "5"  are in different types. How about 2+3 and "2+3" Review Exercise 1  : Write the following input code in your Python program and run the program. What is the output? >>>print(2+3) What is the type of 2+3? Review Exercise 1  : Write the following input code in your Python program and run the program. What is the output? >>>print("2+3") What is the type of "2+3"? The output in Review Exercise 1 is  5 . The output in Review Exercise 2 is 2+3. This is because  2  and  3  are intergers. Python operates adding  2  and  3  . In this case,  2  and  3  are called operands and  +  is the operator. The type of 2+3 is integer while "2+3" is string. Different   Operator Name Example Output  + addition x+y  the value of x+y  - subtraction x-y ...