0% found this document useful (0 votes)
3 views2 pages

Python For Data Science Unit4 Week1 Assignment

The document contains a series of assignment questions related to Python programming, specifically focusing on variable names, operator precedence, code output predictions, and data types. Each question presents multiple-choice answers for students to select from. The questions cover various fundamental concepts in Python, including arithmetic operations, type conversions, and logical expressions.

Uploaded by

ramdalal57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python For Data Science Unit4 Week1 Assignment

The document contains a series of assignment questions related to Python programming, specifically focusing on variable names, operator precedence, code output predictions, and data types. Each question presents multiple-choice answers for students to select from. The questions cover various fundamental concepts in Python, including arithmetic operations, type conversions, and logical expressions.

Uploaded by

ramdalal57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python for Data Science

Unit 4 – Week 1

Assignment Questions
1. Which of the following variable names are INVALID in Python?
a) 1_variable
b) variable_1
c) variable1
d) variable#

2. Which of the following operators have lower precedence than not in Python?
a) +
b) and
c) ==
d) |

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


a = 10 b = 5 print(a ** b % 3)
a) 0
b) 100
c) 1
d) 2

4. What will be the output of the following code snippet?


greetings = "Namaste" greetings_1 = float(greetings) print(type(greetings_1))
a) int
b) float
c) str
d) Code will throw an error

5. Given two variables j = 6 and g = 3.3. If both normal division and floor division operators are used
to divide j by g, what would be the data type of the values obtained?
a) float, float
b) float, int
c) int, float
d) int, int

6. What will be the output of the following code snippet?


a = "10" b = float(a) + 5 result = str(b) + "123" print(type(result))
a) <class 'float'>
b) <class 'str'>
c) <class 'int'>
d) The code will give an error

7. What will be the output of the following code snippet?


a = 15 b = 3 c = 4 result = a + b * c // (c % b) - 5 print(result)
a) 20
b) 1
c) 22
d) 0
8. What is the output of the following code snippet?
a = 4 b = 5 a *= b * 2 print(a)
a) 10
b) 20
c) 25
d) 40

9. What is the output of the following code snippet?


a = 3 b = 5 c = (a == 3) and (b == 5) or (a != 3) print(c)
a) True
b) False
c) Error

10. Let a = 5 (101 in binary) and b = 3 (011 in binary). What is the result of the following operation?
a = 5 b = 3 print(a & b)
a) 3
b) 7
c) 5
d) 1

You might also like