CodeTantra Python Programming L15 Solution

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

Codetantra python programming l15

Q1 :- L15/Building Blocks of Algorithms/Building blocks of Algorithms :- Select the correct statements given below

Selection, Sequence are the only building blocks of constructing an algorithm.

A statement is a collection of instructions corresponding to multiple actions.

Input to a computer, processing the Input and showing the processed result as output are examples of a statement

Execution of individual statements in a given order is called control flow

In selection statement, the program control is transferred to a part of the program based on a condition.

A function causes the control to be passed to block of code when referenced using its name.

Q2 :- L15/Building Blocks of Algorithms/Algorithm and Program to add two numbers :- Understand and retype the below code.

num1=int(input(“num1:.”))

num2=int(input(“num2:.”))
sum = num1 + num2

print(“sum-of-%d,%d-%d” %(num1, num2, sum))

Q3 :- L15/Building Blocks of Algorithms/Algorithm and program to illustrate selection :- Write a program to find the person is eligible to vote or not. Take the age as input from int Print the result as shown in the examples.

age = int(input(“age: “))

if(age >= 0):

   if (age >= 18):

     print(“eligible”)

     else:

        print(“not eligible”)

else:

    print(“age cannot be negative”)

Q4 :- L15/Building Blocks of Algorithms/Example to illustrate Iteration0000000000000 :- Let's consider an example for developing an algorithm and the corresponding program to print natural numbers from (1 to 50)

n = int(input(“n: “))

if (n<=1 or n<=50):

    for i in range(1, n+1):

        print(i,end=””)

else:

     print(“enter valid value”)

Q5 :- L15/Building Blocks of Algorithms/Addition of two numbers using functions :- Follow the instruction and write the code in the space provided:

def add2Num():

num1 = int(input(“num1: “))

num2 = int(input(“num2: “))

sum = num1 + num2

print(“The sum of {} and {} is {}”.format(num1, num2, sum))

add2Num() # caling the function add2Num

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 *