Code Cell Questions#

Question-1#

Perform each of the following algebraic operations in a separate code cell:

  • 20 - 3

  • 72 + 34

  • \(46 \div 4\)

  • \(4 \times 12\)

  • \(5^3\)

Solution

print(20-3)

17

Solution

print(72+34)

106

Solution

print(46/4)

11.5

Solution

print(4*12)

48

Solution

print(5**3)

125

Question-2#

Find the difference between the maximum and minumum of the following numbers: \(65, 23, 1, 2, 3, 90, 99, 12, 34, 67\) using the built-in max() and min() functions.

Solution

print(max(65, 23, 1, 2, 3, 90, 99, 12, 34, 67)-min(65, 23, 1, 2, 3, 90, 99, 12, 34, 67))

Question-3#

Print the string ‘Python’ five times using string repetition.”

Solution

print('Python'*5)

Question-4#

Print the mean, median, mode, and standard deviation of the following list of numbers: \([12, 3, 12, 9, 7, 3, 25, 6]\), using the statistics module.

  • You can refer to the available functions in the statistics module using dir(statistics) or help(statistics).

Solution

import statistics

print(statistics.mean([12, 3, 12, 9, 7, 3, 25,6]))
print(statistics.median([12, 3, 12, 9, 7, 3, 25,6]))
print(statistics.mode([12, 3, 12, 9, 7, 3, 25,6]))
print(statistics.pstdev([12, 3, 12, 9, 7, 3, 25,6]))    # population std
print(statistics.stdev([12, 3, 12, 9, 7, 3, 25,6]))     # sample std

Question-5#

Print the square root of 75 using the math, statistics and numpy modules.

Solution

import math, statistics, numpy

print(math.sqrt(75)) print(statistics.sqrt(75)) print(numpy.sqrt(75))