Hello Coders, In this blog post, you will find all the Solutions to the L3 questions of the Codetantra Python Programming Course. Here are the answeres to these questions:-
Q1:- L3/Variables and Assignment/Understanding Variables :- Fill in the missing code as per the instructions given in the comments.
#In the below line, assign value 18 to the Length variable
length = 18
# In the below line, assign value “King Cobra” to the snake variable
snake = “King Cobra”
print(snake, “can grow up to a length of”, length, “feet”)
Q2:- L3/Variables and Assignment/Assigning Different Values to Variables :- Fill the missing code in the given program as per the below instructions:
1. Assign the variable value1 with value 99
2. Assign the variable value2 with string value "Hello Python"
3. Assign the variable value3 with string value "Hello World™ then print the variables in the same order.
value1= value2 = value3 =”Hello”
print(value1)
print(value2)
print(value3)
# Assign values to variables and print again
value=99
value2 = “Hello Python”
value3 = “Hello World”
print(value1)
print(value2)
print(value3)
Q3:- L3/Variables and Assignment/Assignment of Variables :- Complete the given code in which
1. A variable kilometers is created and you need to assign an integer value to it
2. A variable convert factor is created and 0,621371 is assigned to it,
3. Calculate the product of kilometers and convert factor and assign it to miles variable which is
already created.
4. Print the value of miles as Miles miles where miles is the calculated value
kilometers = int(input(“Enter a value: “))
# assign the correct value
Convertfactor = 0.621371
# assign the correct value
miles = (convertfactor) * (kilometers)
# multiply kilometers and convertfactor
print(“Miles:”, miles)
Q4:-L3/Variables and Assignment/Understanding Multiple Assignment :- Fill in the missing code in the given program to assign the integer value (25) to the variable named age, float value 24.789 to the variable named length and the string value "Python" to the variable named language using multiple assignment syntax so that their individual values are printed by the existing code.
age, length, language =25,24.789, “Python”
#Assign the values to the variables
print(age)
print(length)
print(language)
Q5:L3/Variables and Assignment/Chained Assignment :- Write a program to assign a user given value to a, b, c variables.
str1 input(“Enter a value: “)
a=b=c =str1
# Assign strl to three objects a, b and c
print(“Value of a:”, a) # Print a
print(“Value of b:”, b ) # Print b
print(“Value of c:”, c ) # Print c
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.