Computer Science, asked by pracheesingh8, 9 months ago

Give the output of the following when num1 = 4, num2 = 3, num3 = 2 a) num1 += num2 + num3 b) print (num1) c) num1 = num1 ** (num2 + num3) d) print (num1) e) num1 **= num2 + c f) num1 = '5' + '5' g) print(num1) h) print(4.00/(2.0+2.0)) i) num1 = 2+9*((3*12)-8)/10 j) print(num1) k) num1 = float(10) l) print (num1) m) num1 = int('3.14')

Answers

Answered by mohammedsuleiman046
2

Answer:

Explanation:

Operators are the symbols which tells the Python interpreter to do some mathematical or logical operation. Few basic examples of mathematical operators are given below:

>>> 2 + 3

5

>>> 23 - 3

20

>>> 22.0 / 12

1.8333333333333333

To get floating result you need to the division using any of operand as floating number. To do modulo operation use % operator

>>> 14 % 3

2

Example of integer arithmetic

The code

#!/usr/bin/env python3

days = int(input("Enter days: "))

months = days / 30

days = days % 30

print("Months = %d Days = %d" % (months, days))

The output

$ ./integer.py

Enter days: 265

Months = 8 Days = 25

In the first line I am taking the input of days, then getting the months and days and at last printing them. You can do it in a easy way

#!/usr/bin/env python3

days = int(input("Enter days: "))

print("Months = %d Days = %d" % (divmod(days, 30)))

The divmod(num1, num2) function returns two values , first is the division of num1 and num2 and in second the modulo of num1 and num2.

Similar questions