The Joy of Computing Using Python | Week 2
Session: JAN-APR 2024
Course Name: The Joy of Computing using Python
Course Link: Click Here
For answers or latest updates join our telegram channel: Click here to join
These are the Joy of Computing using Python Assignment 2 Answers
Q1. At any given point during a program’s execution, what value is held within a variable?
The value it was initially assigned when it was created.
The sum of all values that have ever been assigned to it.
The most recent value that was assigned to it.
The average of all values that have ever been assigned to it.
Answer: The most recent value that was assigned to it.
Q2. What will be the output of the following Python code snippet?
Which of the following represents the correct output if the user inputs “25”?
The value is: 25
25
The value is:
None of the above
Answer: The value is: 25
Q3. What are the possible loop values that can be specified in the range argument of a for loop in Python, and why are these values used?
Integers, representing the starting and ending points of the loop, allowing iteration through a specified range of numbers.
Floating-point numbers, enabling iteration through decimal ranges with precise steps.
Strings, facilitating iteration through characters in a specified string
Tuples, allowing iteration through multiple sequences simultaneously.
Answer: Integers, representing the starting and ending points of the loop, allowing iteration through a specified range of numbers.
For answers or latest updates join our telegram channel: Click here to join
These are the Joy of Computing using Python Assignment 2 Answers
Q4. What values can be used in the argument of a while loop in Python, and why are these values used?
Integers, representing the starting and ending points of the loop, allowing iteration through a specified range of numbers
Boolean expressions or conditions, enabling the loop to execute until the condition becomes False.
Floating-point numbers, allowing iteration through decimal ranges with precise steps.
Strings, facilitating iteration through characters in a specified string.
Answer: Boolean expressions or conditions, enabling the loop to execute until the condition becomes False.
Q5. What types of conditional entries can be used in a Python if statement, and why are these entries used?
Integers, representing specific numeric values to check against a variable, ensuring a match for equality
Boolean expressions or conditions, evaluating to True or False and determining the path of execution in the code.
Strings, enabling comparison of text values for exact matches in the condition
Floating-point numbers, allow range-based conditions to check if a variable falls within a specific numerical range.
Answer: Boolean expressions or conditions, evaluating to True or False and determining the path of execution in the code.
Q6. Consider the following code snippet:
What does the code do?
Takes an input n, computes the multiplication table of n from 1 to 10, and prints each multiplication.
Takes an input n, computes the multiplication table of n from 1 to 11, and prints the final product.
Takes an input n, computes the multiplication table of n from 1 to 10, and prints the final product.
Takes an input n, initializes i to 1, and prints the multiplication of n and i without any loop.
Answer: Takes an input n, computes the multiplication table of n from 1 to 10, and prints each multiplication.
For answers or latest updates join our telegram channel: Click here to join
These are the Joy of Computing using Python Assignment 2 Answers
Q7. Consider the following code snippet:
What does the code do?
Takes an input number, computes the multiplication table of numbers from 1 to 10, and prints each multiplication
Takes an input number, computes the multiplication table of numbers from 1 to 11, and prints the final product.
Takes an input number, computes the multiplication table of numbers from 1 to 10, and prints the final product.
Takes an input number, initializes i to 1, and prints the multiplication of number and i without any loop.
Answer: Takes an input number, computes the multiplication table of numbers from 1 to 10, and prints each multiplication
Q8. Consider the following code snippet:
What does the code do?
Takes an input num, computes the factorial of num, and prints the factorial value.
Takes an input num, computes the product of numbers from 1 to num, and prints the final product.
Takes an input num, computes the sum of numbers from 1 to num, and prints the final sum.
Takes an input num, initializes the result to 1, and prints the value of the result without any factorial computation.
Answer: a, b
Takes an input num, computes the factorial of num, and prints the factorial value.
Takes an input num, computes the product of numbers from 1 to num, and prints the final product.
Q9. An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. Which of the following are IDEs?
PyCharm
Spyder
Visual Studio Code (VS Code)
C# (pronounced “C sharp”)
Answer: a, b, c
PyCharm
Spyder
Visual Studio Code (VS Code)
These are the Joy of Computing using Python Assignment 2 Answers
Q10. A Python distribution is a software bundle, which contains a Python interpreter and the Python standard library. What is Anaconda being discussed in lectures?
A species of snake
A type of programming language
An integrated development environment (IDE)
A Python distribution for scientific computing and data science
Answer: A Python distribution for scientific computing and data science
For answers or latest updates join our telegram channel: Click here to join
These are the Joy of Computing using Python Assignment 2 Answers
More Weeks of The Joy of Computing Using Python: Click here
More Nptel Courses: Click here
Session: JULY-DEC 2023
Course Name: The Joy of Computing using Python
Course Link: Click Here
These are the Joy of Computing using Python Assignment 2 Answers
Q1. Which of the following is a high-level programming language?
Assembly
C
Python
Machine Language
Answer: Python
Q2. Which of the following is an example of a front-end programming language?
PHP
Java
HTML
SQL
Answer: HTML
Q3. Which of the following is used to store data in a programming language?
Variables
Arrays
Loops
Conditionals
Answer: a, b
These are the Joy of Computing using Python Assignment 2 Answers
Q4. Which statement will print ‘The joy of computing’?
print(The joy of computing)
print The joy of computing
printf(‘The joy of computing’)
print(‘The joy of computing’)
Answer: print(‘The joy of computing’)
Q5. What should be the value of _ to print all numbers from 0-10
10
9
11
None of the above
Answer: 11
Q6. Which of the following keyword is used to declare a function in a programming language?
def
var
int
float
Answer: def
These are the Joy of Computing using Python Assignment 2 Answers
Q7. What will be the output of the following code?
0
45
43
50
Answer: 45
Q8. What value will c store in it after the execution of the below code?
c=b**3
Value of b multiplied by 3
Cube of b
Value of b multiplied with 3 twice
It will throw an error
Answer: It will throw an error
Q9. What will be the output? suppose the input is 30
60
Error
3030
30
Answer: 3030
These are the Joy of Computing using Python Assignment 2 Answers
Q10. What is the output for the following program?
True
False
It will display an error message
Boolean
Answer: False
These are the Joy of Computing using Python Assignment 2 Answers
More Weeks of The Joy of Computing Using Python: Click here
More Nptel Courses: Click here
Session Jan-Apr 2023
Course Name: The Joy of Computing using Python
Course Link: Click Here
These are the Joy of Computing using Python Assignment 2 Answers
Q1. What are the applications of Python?
a. Image processing and graphic design applications
b. Enterprise and business applications development
c. Operating systems
d. All of the above
e. None of the above
Answer: d. All of the above
Q2. Which of the following is not the correct variable name
a. Abc
b. Abd23
c. 32asd
d. Ab_cd_23
Answer: c. 32asd
Q3. Write the output of the following code.
L = [1,2,3,4,5,6,7,8,9]
print(L[::-1])
a. [1,2,3,4,5,6,7,8,9]
b. [1,2,3,4,5,9,8,7,6]
c. [9,8,7,6,5,4,3,2,1]
d. Error
Answer: c. [9,8,7,6,5,4,3,2,1]
These are the Joy of Computing using Python Assignment 2 Answers
Q4. Predict the output of the following code:
L = [[1,2,3],[0,4,5],[0,0,6]]
a. 3,2,1,5,4,6
b. 3 2 1 5 4 6
c. 0,0,0,0,0,0
d. 0 0 0 0 0 0
Answer: b. 3 2 1 5 4 6
Q5. Find all the error(s)in the following code:
a. Index out of range
b. Syntax error
c. Variable not defined
d. ‘int’ object does not support item assignment
Answer: a, b
Q6. What is the output of the following code:
a. [0,1,2] (5,3,4)
b. [0,1,2] (5,)
c. [0] (5,3,4)
d. [0] (5,)
Answer: b. [0,1,2] (5,)
These are the Joy of Computing using Python Assignment 2 Answers
Q7. What is the correct syntax for defining a function in Python?
a. def function name():
b. function function_name():
c. function_name():
d. def function_name:
Answer: a. def function name():
Q8. What is the purpose of the continue statement in a for loop?
a. To skip the rest of the current iteration and move on to the next one
b. To terminate the loop and exit the loop block
c. To return to the top of the loop and start a new iteration
d. To skip the current iteration and move on to the next one, but only if a certain condition is met
Answer: a. To skip the rest of the current iteration and move on to the next one
Q9. How do you check if a number is even in Python?
a. if number % 2 == 0
b. if number.is_even()
c. if number % 2 is 0
d. if number.even()
Answer: a. if number % 2 == 0
These are the Joy of Computing using Python Assignment 2 Answers
Q10. What should be the value of _ to print all numbers from 0-10?
a. 11
b. 9
c. 10
d. None of the above
Answer: a. 11
The Joy of Computing using Python Programming Assignmnet
Question 1
Given an integer as an input, write a program to print that integer.
Input
A number
Output
A number
Solution:
print(num)
These are the Joy of Computing using Python Assignment 2 Answers
Question 2
Given two integers as an input, write a program to print the sum of those two integers.
Solution:
print(num1 + num2)
These are the Joy of Computing using Python Assignment 2 Answers
Question 3
You are given a number as an input. You have to display all the numbers from 0 till x.
Input
x
Output
0
1
2
.
.
x
Solution:
for i in range(num+1):
print(i)
These are the Joy of Computing using Python Assignment 2 Answers
More Weeks of The Joy of Computing using Python: Click Here
More Nptel courses: https://progiez.com/nptel-assignment-answers/
Session JUL-DEC 2022
These are the Joy of Computing using Python Assignment 2 Answers
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
These are the Joy of Computing using Python Assignment 2 Answers
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
These are the Joy of Computing using Python Assignment 2 Answers
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
These are the Joy of Computing using Python Assignment 2 Answers
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)
These are the Joy of Computing using Python Assignment 2 Answers