The Joy of Computing using Python Week 2 Assignment

                     

Course name: The Joy of Computing Using Python

Link to Enroll: https://onlinecourses.nptel.ac.in/noc21_cs32/preview

This is an assignment for The joy of computing using python NPTEL

Q1. What is the correct command to show the value stored in a variable?

a) show()
b) cout()
c) print()
d) out()

Ans:- c


Q2. What will be the output of the following piece of code?

a)Hello Mr. Bond 34
b) Hello Mr. 34
c) Hello Mr. Bond 35
d) Hello Mr. Bond 34

Ans:- c


Q3. What will be the output of the following code?

a) 10,10
b)10
c)no output
d)error

Ans:- d


Q4. What is the extension of a python file?

a) sc
b) py
c) md
d)cp

Ans:- b


Q5. what will be the output of the following code, if the given input is 5?

A = input()

print(A*5)

a)25
b)55555
c)55
d)5

Ans:- b


This is an assignment for The joy of computing using python NPTEL


Q6. Which of the following commands are correct to take input from a user?
a) n = input(‘Hello’)
b) n = input(“42”)
c) n = input(‘42’)
d) n = input(Hello)

e) n= input()

Ans:- a,b,c,e


Q7. What will be the output of the following code if the input is ‘5’?
a)25

b)25.0
c) Error
d) 5555

Ans:- a


This is an assignment for The joy of computing using python NPTEL


Q8. Which of the following blocks of codes are correct?(Assume x and y are initialized)

Ans:- b


Q9. Which of the following statements are correct regarding the following code?

Ans:- Update Soon…


Q10. What will be the output of the following code?

Ans:- b


The joy of computing using python coding Assignment NPTEL

Q1. Write a program to take an input from the user and print that input.

string = input()
print(string, end="")

Q2. Write a program to take an input of two numbers A, and B and print the difference A-B

Code:-

A = int(input())
B = int(input())

z = A-B

print(z, end="")

Q3. Take a string S and an integer A as an input from a user. Write a program to print string S, A number of times.

Code:-

S = input()
A = int(input())

for i in range(1,A+1):
    print(S)

This is an assignment for The joy of computing using python NPTEL

More NPTEL course answers: Click me

* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first.