In this blog post, you will find all the Solutions to the L9 questions of the Codetantra Python Programming Course. Here are the answere to these question:-
Q1 :- L9/Arithmetic Operators/Arithmetic Operators - An overview :- Select all the correct statements from the given options.
Python supports 7 arithmetic operators.
An exponent operator is represented by ** in Python.
If the result of a division of two numbers is a floating point number, then it is rounded off to the nearest number. This is called Modulus division.
The result of the division is not considered, but the remainder is considered, it is known as Floor Division.
// is called as Floor division operator
Q2 :- L9/Arithmetic Operators/Using Arithmetic Operators :- Write a program to read two int inputs from the user and display the results of the following arithmetic operations
#Arithmetic Operators are +,-,*,/,**,%, //
num1 = int(input(“num1: “))
num2 = int(input(“num2: “))
print(num1, “+”, num2, “=”, num1+num2)
print(num1,”-“, num2,”=”, num1-num2)
print(num1,”*”, num2, “=”, num1*num2)
print(num1,”/”,num2, “-“, num1/num2)
print(num1, ““, num2, “-“, num1num2)
print(num1, “%”, num2, “=”, num1%num2)
print(num1,”//”, num2,”=”, num1//num2)
Q3 :- L9/Arithmetic Operators/Writing a program on on arithmetic operators :- Write a program to read two int, inputs from the user and perform the following arithmetic operations addition subtraction, multiplication, and livator, and print the result
num1 = int(input (“num1: “))
num2 = int(input (“num2: “))
print(“Addition of”, num1, “and”, num2, “-“, num1+num2)
print(“Subtraction of”, num1,”and”, num2, “-“, num1-num2) print(“Multiplication of”, num1, “and”, num2, “=”, num1*num2)
print(“Division of”, num1, “and”, num2,”=”, num1/num2)
Q4 :- L9/Arithmetic Operators/Some more arithmetic operators :- Write the program to read two Integer inputs from the user and perform the following arithmetic operations over it
num1 = int(input(“num1: “))
num2 = int(input(“num2: “))
print(“Exponent of”, num1, “with”, num2, “=”, num1**num2)
print(“Modulus of”, num1, “and”, num2, “=”, num1%num2)
print(“Floor Division of”, num1, “and”, num2, “-“, num1//num2)
Q5 :- L9/Arithmetic Operators/Writing a program on some more arithmetic operators :- The program should take two integer, inputs from the user and print the result of the above-mentioned arithmetic operators
a = int(input(“num1: “))
b = int(input(“num2: “))
print(“Exponent of”, a, “with”, b, “=”, a**b)
print(“Modulus of”, a, “and”, b, “=”, a%b)
print(“Floor Division of”,a,”and”,b,” =”,a//b)
Q6 :- L9/Arithmetic Operators/Explanation of divmod function :- Write a program to find quotient and remainder of the given two values using divmod()
a = int(input(“num1: “))
b = int(input(“num2: “))
print(a,’//’,b,’=’, a//b)
print(a, ‘%’,b,’=’,a%b)
Q7 :- L9/Comparison Operators/Comparison Operators - An overview :- Write a program to understand the comparison operators in Python and perform the following operations>.. = and print the result. Take two int inputs from the
num1 = int(input(“num1: “)
num2 = int(input(“num2: “))
print(“Is {} greater than {} -“.format(num1, num2), num1>num2);
print(“Is {} less than {} =”.format(num1, num2), num1 <num2);
print(“Is {} equal to {} =”.format(num1, num2), num1=-num2);
print(“Is {} not equal to {} -“.for -“.format(num1, num2), num1!=num2);
print(“Is {} less than or equal to {}”.format(num1, num2), num1<=num2);
print(“Is {} greater than or equal to {}”.format(num1, num2), num1> num2);
Q8 :- L9/Comparison Operators/Using Comparison operators :- Take two integers as input from the console using input() function. For each comparison operator (><) print to the console, the result of the two input numbers as shown in the example.
a = int(input(“num1: “))
b = int(input(“num2: “))
print(“Is {} greater than {} =”.format(a,b), a>b)
print(“Is {} less than {} -“.format(a,b), a<b)
print(“Is {} equal to {} =”.format(a,b),a==b)
print(“Is {} not equal to {} =”.format(a,b),al=b)
print(“Is {} greater than or equal to {} =”.format(a,b), a>=b)
print(“Is {} less than or equal to {} =”.format(a,b), a<=b)
Q9 :- L9/Comparison Operators/Comparison operators with strings :- Write a program to understand the use of comparison operators using conditional parameters. Take input from user using input method
a= input(“str1: “)
b= input(“str2: “)
print(“Is {} greater than {} =”.format(a,b), a>b)
print(“Is {} less than {} =”.format(a,b), a<b)
print(“Is {} equal to {} =”. format(a,b),a==b)
print(“Is {} not equal to {} =”.format(a,b), al-b)
print(“Is {} greater than or equal to {} =”.format(a,b), a>=b)
print(“Is {} less than or equal to {} =”.format(a,b), a<=b)
Q10 :- L9/Comparison Operators/Writing Comparison Operators on Strings :- Take two strings as input from the console using input() function. For each of the comparison operators (>,<) print to the console, the result of the comparison of the two input strings as shown in the example below
str1 = input(“str1: “)
str2 = input(“str2: )
print(“Is {} greater than {} -“.format(str1,str2), str1>str2)
print(“Is {} less than {}”.format(str1,str2), str1<str2)
print(“Is {} equal to (}”.format(str1, str2), str1==str2)
print(“Is {} not equal to {} =”.format(str1, str2), str1!=str2)
print(“Is {} greater than or equal to {} =”.format(str1,str2), str1>=str2)
print(“Is {} less than or equal to {}”.format(str1, str2), str1<=str2)
Hope this blog post was helpful to you and you have got the answer to your question. Thank you for visiting our blog. If you have any doubts about any coding questions then let us know in the comments section we will answer them as soon as possible. Till then check out our more blog posts.