CodeTantra Python Programming L12 Solution

In this blog post, you will find all the Solutions to the L12 questions of the Codetantra Python Programming Course. Here are the answere to these question:-

codetantra python programming l12

Q1 :- L12/Identity Operators/Identity Operators-An overview :- Select the correct statement given below

An identity can be changed once created.

Two strings with same value point to different locations

id(object) is unique and Constant for an object during its lifetime.

Q2 :- L12/Identity Operators/Identity Operators- An overview :- For each Identity operator is and is not print to the console, the result of the two float numbers as shown in the example

x = int(input(“Enter an integer: “))
y = int(input(“Enter the same integer: “))

print(“x is y”,x is y)

print(“x is not y”, x is not y)

x = float(input(“Enter a Float Number: “))

y = float(input(“Enter the same Number: “))

print(“x is y”,x is y)

print(“x is not y”,x is not y)

Q3 :- L12/Identity Operators/Writing using Identity "is" :- Using the identity operator is check if x and y are the same objects or not, print to the console the result of the two input integers as shown in the example

x = int(input(“x: “))

y = int(input(“y: “))

print(“{} is {}”.format(x,y),x is y)

Q4 :- L12/Identity Operators/Writing an example using identity operator "is not" :- Take two integers x and y as input from the console using input() function. Using the identity operator is not check if x and y are same objects or not, print to the console, the result of the two input integers as shown in the example.

x = int(input(“x: “)

y = int(input(“y: “))

print(“{} is not {}”.format(x,y),x is not y)

Q5 :- L12/Operators Precedence/Operator Precedence & Associativity - definitions :- Select the correct statements given below.

Operator precedence is performed based on priority of an operator.

Associativity is used when two operators of same precedence are in the same expression.

Associativity is only from Left to Right.

The operator precedence is only used on Arithmetic operators.

Q6 :- L12/Operators Precedence/Operator Precedence :- Follow the given instructions and complete the code given below:

a = int(input(“a: “))

b = int(input(“b: “))

print(“{} + {} * 5 =”.format(a,b), a+b*5)

print(“{} + {} * 6 / 2 =”.format(a,b), a+b*6/2)

Q7 :- L12/Operators Precedence/Writing an example on operator precedence :- Print to the console, the result of the two input integers after performing these operations as shown in the example

a = int(input(“a: “))

b = int(input(“b: “))

print(“{} + {} * 5 =”.format(a,b), a+b*5)

print(“{} + {} *5*10/2=”.format(a,b), a+b*5*10/2)

Q8 :- L12/Operators Precedence/Using operator precedence on Logical operators :- Follow the given instructions and complete the code.

a = int(input(“a: “))

b = int(input(“b: “))

c = int(input(“c: “))

print(“a and b or c”, a and b or c)

print(“a or b and c”, a or b and c)

Q9 :- L12/Operators Precedence/Using Operator Precedence on Logical Operators ;- For each expression, print to the console, the result of the three input integers as shown in the example.

a = int(input(“a: “))

b = int(input(“b: “))

c = int(input(“c: “))

print(“{} and {} and {} or {} is”.format(a,b,c,a), a and b and c or a)

print(“{} or {} and {} and {} is”.format(a,b,c,a), a or b and c and a)

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.

Leave a Comment

Your email address will not be published. Required fields are marked *