40 solutions available
Question 1What are data types in Python? How are they important?
Question 5How many string types does Python support? How are they different from one another?
Question 10Are these values equal? Why/why not?20 and 20.020 and int(20)str(20) and str(20.0)'a' and "a"
Question 12What is the difference between implicit type conversion and explicit type conversion?
Question 14Given str1 = "Hello", what will be the values of:(a) str1[0](b) str1[1](c) str1[-5](d) str1[-4](e) str1[5]
Question 19Given three Boolean variables a, b, c as : a = False, b = True, c = False. Evaluate the following Boolean expressions:(a) b and c(b) b or...
Question 21Write following expressions in Python:(a) 13b2h\dfrac{1}{3} b^2 h31b2h
Question 26Evaluate and Justify:(i) 22.0/7.0 - 22/7(ii) 22.0/7.0 - int(22.0/7.0)(iii) 22/7 - int (22.0)/7
Question 27Evaluate and Justify:(i) false and None(ii) 0 and None(iii) True and None(iv) None and None
Question 28Evaluate and Justify:(a) 0 or None and "or"(b) 1 or None and 'a' or 'b'(c) False and 23(d) 23 and False(e) not (1 == 1 and 0 != 1)(f)...
Question 29Evaluate the following for each expression that is successfully evaluated, determine its value and type for unsuccessful expression, state...
Question 30Write an expression that uses exactly 3 arithmetic operators with integer literals and produces result as 99.
Question 33In Python, strings are immutable while lists are mutable. What is the difference?
Question 34How does the // operator differ from the / operator? Give an example of where // would be needed.
Question 36What are main error types? Which types are most dangerous and why?
Question 37Correct any false statements:(a) Compile-time errors are usually easier to detect and to correct than run-time errors.(b) Logically errors...
Question 38Differentiate between a syntax error and a semantics error.
Question 39Differentiate between a syntax error and a logical error in a python program. When is each type of error likely to be found?
Question 40What is the difference between an error and exception?
Question 5aWhat will be output produced by following code? State reason for this output.a, b, c = 1, 1, 2 d = a + b e = 1.0 f = 1.0 g = 2.0 h = e + f...
Question 5bWhat will be output produced by following code? State reason for this output.a = 5 - 4 - 3 b = 3**2**3 print(a) print(b)
Question 5cWhat will be output produced by following code? State reason for this output.a, b, c = 1, 1, 1 d = 0.3 e=a+b+c-d f=a+b+c == d print(e)...
Question 6aWhat will be the output of following Python code?a = 12 b = 7.4 c = 1 a -= b print(a, b) a *= 2 + c print(a) b += a * c...
Question 7Make change in the expression for z of previous question so that the output produced is zero. You cannot change the operators and order of...
Question 11Find out the error and the reason for the error in the following code. Also, give the corrected code.a, b = "5.0", "10.0" x = float(a/b)...
Question 13Consider the following program. It is supposed to compute the hypotenuse of a right triangle after the user enters the lengths of the...
Question 17Predict the output if e is given input as 'True':a = True b = 0 < 5 print (a == b) print (a is b) c = str (a) d = str (b) print (c ==...
Question 19cWhat will be the output produced?s = 'Sipo' s1 = s + '2' s2 = s * 2 print(s1) print(s2)
Question 19dWhat will be the output produced?w, x, y, z = True , 4, -6, 2 result = -(x + z) < y or x ** z < 10 print(result)
Question 22Consider the code given below:import random r = random.randint(10, 100) - 10 print(r, end = ' ') r = random.randint(10, 100) - 10 print(r,...
Question 2Write a program to obtain temperatures of 7 days (Monday, Tuesday ... Sunday) and then display average temperature of the week.Solutiond1 =...
Question 3Write a program to obtain x, y, z from user and calculate expression : 4x4 + 3y3 + 9z + 6πSolutionimport math x = int(input("Enter x: "))...
Question 4Write a program that reads a number of seconds and prints it in form : mins and seconds, e.g., 200 seconds are printed as 3 mins and 20...
Question 13Write a program that generates six random numbers in a sequence created with (start, stop, step). Then print the mean, median and mode of...
Question 16Write a program to generate 6 random numbers and then print their mean, median and mode.Solutionimport random import statistics a =...
Question 18Write a program to calculate the radius of a sphere whose area (4πr2) is given.Solutionimport math area = float(input("Enter area of...
Question 20Find the volume of the cylinder (πr2h) as shown:Radius = 8 cmHeight = 15 cmSolutionimport math r = 8 h = 15 v = math.pi * r * r * h...
Question 23Write a program to calculate amount payable after simple interest.Solutionp = float(input("Enter principal: ")) r = float(input("Enter...
Question 24Write a program to calculate amount payable after compound interest.Solutionp = float(input("Enter principal: ")) r = float(input("Enter...
Question 25Write a program to compute (a + b)3 using the formula a3 + b3 + 3a2b + 3ab2Solutiona = int(input("Enter a: ")) b = int(input("Enter b: "))...