Python for Data Science NPTEL | Week 1
Session: JAN-APR 2024/JULY-DEC 2023
Course name: Python For Data Science
Course Link: Click Here
For answers or latest updates join our telegram channel: Click here to join
These are NPTEL Python for Data Science Assignment 1 Answers
Q1. What is the output of the following code?
36
121212
123
Error: Invalid operation, unsupported operator ‘*’ used between ‘int’ and ‘str’
Answer: 121212
Q2. What is the output of the following code?
-1
-2
-1.28
1.28
Answer: -2
Q3. Consider a following code snippet. What is a data type of y?
int
float
str
Code will throw an error.
Answer: str
For answers or latest updates join our telegram channel: Click here to join
These are NPTEL Python for Data Science Assignment 1 Answers
Q4. Which of the following variable names are INVALID in Python?
1_variable
variable_1
variable1
variable#
Answer: [A, D] 1_variable, variable#
Q5. While naming the variable, use of any special character other than underscore(_) ill throw which type of error?
Syntax error
Key error
Value error
Index error
Answer: Syntax error
Q6. Let x = “Mayur”. Which of the following commands converts the ‘x’ to float datatype?
str(float,x)
x.float()
float(x)
Cannot convert a string to float data type
Answer: Cannot convert a string to float data type
For answers or latest updates join our telegram channel: Click here to join
These are NPTEL Python for Data Science Assignment 1 Answers
Q7. Which Python library is commonly used for data wrangling and manipulation?
Numpy
Pandas
scikit
Math
Answer: Pandas
Q8. Predict the output of the following code.
12.0
12
11.667
11
Answer: 12
Q9. Given two variables, j = 6 and g = 3.3. If both normal division and floor division operators were used to divide j by g, what would be the data type of the value obtained from the operations?
int, int
float, float
float, int
int, float
Answer: float, float
Q10. Let a = 5 (101 in binary) and b = 3 (011 in binary). What is the result of the following operation?
3
7
5
1
Answer: 1
For answers or latest updates join our telegram channel: Click here to join
These are NPTEL Python for Data Science Assignment 1 Answers
More Weeks of Python for Data Science: Click here
More Nptel Courses: Click here
Session: JAN-APR 2023
Course Name: Python for Data Science
Course Link: Click Here
These are NPTEL Python for Data Science Assignment 1 Answers
Q1. Which of the following is/are the correct ways of naming variables in Python?
a. 2_max = 5
b. max_2 = 5
c. max2 = 5
d. max @2 = 5
Answer: b, c
Q2. What does 5%11 will evaluate to
a. 1
b. 5
c. 0
d. Syntax error
Answer: b. 5
Q3. What does 4//7 evaluate to
a. 0
b. 1
c. 0.0
d. 4
Answer: a. 0
These are NPTEL Python for Data Science Assignment 1 Answers
Q4. What will be the output of the following code snippet?
a. 300
b. 100200
c. ‘100’ + ‘200’
d. ‘100 + 200’
Answer: b. 100200
Q5. What will be the output of the following code snippet?
a. 300
b. 100200
c. ‘100’ + ‘200’
d. ‘100 + 200’
Answer: a. 300
Q6. What is the type of the following expression?
1 + 4 / 2
a. int
b. float
c. bool
d. str
Answer: b. float
These are NPTEL Python for Data Science Assignment 1 Answers
Q7. What is the type of the following expression?
[1] (1 > 0) and (-1 < 0) and (1 == 1)
a. str
b. bool
c. True
d. False
Answer: c. True
Q8. What is the output of the following code snippet?
a. 32
b. 44
c. 40
d. 36
Answer: c. 40
Q9. Which of the arithmetic operators given below cannot be used with ‘strings’ in Python?
a. *
b. –
c. +
d. All of the above
Answer: b. –
Q10. Consider the list of instructions and resulting outputs given below. Pick the set that is incorrect.
a. 4
b. 2
c. 1, 3
d. 1, 3, 4
e. All are correct
Answer: b. 2
Q11. Two variables Xand Y were assigned the following values initially: X = 3 and Y = 6. Which of the following statements will help swap the values between these two variables?
a. Y = X
X = Y
b. X = Y
c. X = Y
Y = X
d. X, Y = Y, X
Answer: d. X, Y = Y, X
These are NPTEL Python for Data Science Assignment 1 Answers
Session: JULY-DEC 2022
Q1. What is the output of the following code?
num1 = 12
num2 "58"
print(num1 + num2)
a.12
b.58
c.70
d.Error: Invalid operation, unsupported operator ‘+’ used between ‘int’ and ‘str’
Answer:- d
2. Given two variables j = 6 and g = 3.3. If both normal division and floor division operators were used to divide j by g, what would be the data type of the value obtained from the operations?
a. int, int
b. float, float
c. float, int
d. int, float
Answer:- b
3. Let a = 5 (101 in binary) and b = 3 (011 in binary). Which of the following operations results in the values 7 and 1?
Answer:- b
These are NPTEL Python for Data Science Assignment 1 Answers
4. State whether the given statement is True or False.
When using the floor division operator (//), if the result is negative, then the result is rounded off to the next largest integer.
a. True
b. False
Answer:- b
5. Let x = “50”. Which of the following commands converts the ‘x’ to float datatype?
a. str(float,x)
b. x.float()
c. float(x)
d. Cannot convert a string to float datatype
Answer:- c
6. Which of the following variable names are INVALID in Python?
a. 1_variable
b. variable_1
c. variable_*
d. variable1
Answer:- a, c
These are NPTEL Python for Data Science Assignment 1 Answers
7. Which of the following variable assignments would throw an error?
a. var1=True; var2=False;
b. var1=false; var2=true;
c. var1=’True’; var2=’False’;
d. var1=’true’; var2=’false’;
Answer:- b
8. Predict the output of the following code
x=4
y-11
p 5.0
ans=x**(y % p)
print(ans)
a. 4
b. 4.0
c. 5
d. 4.1
Answer:- b
9. The value of the variable result after running the code snippet below is ____
num-20.5
z-3
result-2+:*3+num/lz
print(result)
a. 89.0
b. 17.0
c. 737.0
d. 96.0
Answer:- b
10. Which Python library is commonly used for data wrangling and manipulation?
a. Numpy
b. Pandas
c. scikit
d. Math
Answer:- b
These are NPTEL Python for Data Science Assignment 1 Answers
More Weeks of Python for Data Science: Click here
More Nptel Courses: Click here