Sunday 19 March 2017

Python Programming part-4 (Exponentiation ,Quotient & Remainder :)

Exponentiation 

Besides addition , subtraction , multiplication , and division , Python also supports exponentation , which is the raising of one number to the power of another . This operation is performed using two asterisks.

>>> 2**5
32
>>> 9**(1/2)
3.0

Question :
Fill in the blank to make this code correct :
>>> (1+__) **2
16

____________________________________________________

Quotient & Remainder :

To determine the quotient and remainder of a division , use thr floor division and modulo operators , respectively .
Floor division is done using two forward slashes .
The modulo operator  is carried out with a percent symbol (%).
These operators can be used with both floats and integers.

This code shows that 6 goes into 20 three times , and the remainder  when 1.25 is divided by 0.5 is 0.25 .

>>> 20 // 6
3
>>> 1.25 // 0.5
0.25

Question :
What is the result of this code ?
>>> 7 % (5//2)
a. 0
b. 1
c. 7

ans . b

____________________________________________________


EmoticonEmoticon