In this blog post, you will find all the Solutions to the L11 questions of the Codetantra Python Programming Course. Here are the answere to these question:-
Q1 :- L11/Logical Operators/Logical Operators - An overview :- Select the correct statement
In logical operators, 1 represents False and 0 represents True.
In logical and the result is true if the both operands are true.
Q2 :- L11/Logical Operators/Logical Operators - An overview :- Follow these instructions to identify whether the person is eligible for the concession or not.
gen = input(“M or F: “)
age = int(input(“age: “))
if ((gen == “M” and age >= 65) or (gen ==’F’ and age >= 60)):
print(“Eligible for Concession”)
else:
print(“Not Eligible for Concession”)
Q3 :- L11/Logical Operators/Writing a program using logical "and" :- Write a program to understand the logical and operator. Take three integers as input from the user using input() function. The program should print True if a is 6 and b is 6 and c is not 6, otherwise it should print False
a = int(input(“a: “))
b = int(input(“b: “))
c = int(input(“c: “))
if (a==6 and b==6 and c!=6):
print(‘True’)
else:
print(‘False’)
Q4 :- L11/Logical Operators/Using Logical "or" :- Write a program to understand the logical or operator. Take two integers a and b as inputs from the console using input() function. The program ogram should print True if either of the inputs is 6, their sum is 6, or their difference is 6 Otherwise it should print False
a = int(input(“a: “))
b = int(input(“b: “))
if (a==6 or b==6 or a-b == 6 or a+b ==6):
print(“True”)
else:
print(“False”)
Q5 :- L11/Logical Operators/Using Logical "not :- Write a program to understand the logical not operator. The program should print Weekend if the day is either SAT or SUN, otherwise it should print Not weekend Jake the input day from the user
a = input(“Enter day: “)
if (a==”SAT” or a == “SUN”):
print(“Weekend”)
else:
print(“Not Weekend”)
Q6 :- L11/Membership Operators/The membership operators :- Select the correct statements given below.
in and not in operators check the existence of a member in a collection.
in operator can be used with numbers.
if in operator returns False, not in operator will return True.
you can check for the existence of multiple members in a list with a single in operator
An empty string is part of every other string
Q7 :- L11/Membership Operators/Membership Operators - an Overview :- Follow the instructions and write the code in the space provided
st = str(input(“str1: “))
st2 = str(input(“str2: “))
print(“{} in {} :”.format(st2,st), st2 in st)
Q8 :- L11/Membership Operators/Writing example using Membership operator in :- Take two strings as input from the console using Input() function. For each membership operator in and not in, print to the console, the result of the two input strings as shown in the example
st = str(input(“str1: “))
st1 = str(input(“str2: “))
print(“{} in {} is:”.format(st1,st), st1 in st)
print(“{} not in {} is:”.format(st1, st), st1 not in st)
Q9 :- L11/Membership Operators/Write an example using Membership operator not in :- Let's write a simple program using the membership operator in and not in
L1 = [‘A’, ‘123’, ‘Ramana’, [1, 2], 34.56, ’55’]
print(L1)
a = input(“element: “)
print(“{} in {} is: “.format(a,L1),a in L1)
print(“{} not in {} is: “.format(a,L1), a not in L1)
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.