0% found this document useful (0 votes)
20 views3 pages

Assignment Python

The document is an assignment focused on Python basics, divided into multiple sections including multiple choice questions, fill in the blanks, true/false statements, predicting outputs, error finding, and writing Python programs. It covers fundamental concepts such as variable naming, operators, data types, and control structures. The assignment aims to assess understanding and application of Python programming skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Assignment Python

The document is an assignment focused on Python basics, divided into multiple sections including multiple choice questions, fill in the blanks, true/false statements, predicting outputs, error finding, and writing Python programs. It covers fundamental concepts such as variable naming, operators, data types, and control structures. The assignment aims to assess understanding and application of Python programming skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment: Python Basics – Revision

Part A: Multiple Choice Questions (MCQs)


Choose the correct option.

Q1. Which of the following is a valid variable name in Python?


a. my-var b. 1name c. _value d. def
Q2. Which operator is used for floor division in Python?
a. / b. // c. % d. **
Q3. What will be the output of the expression 3 + 4 * 2?
a. 14 b. 11 c. 10 d. 7
Q4. What does bool('False') return?
a. True b. False c. None d. Error
Q5. Which of the following is a logical operator in Python?
a. & b. | c. and d. +
Q6. What is the output of 5 ** 2?
a. 25 b. 10 c. 7 d. 32
Q7. Which of the following is used to check identity in Python?
a. == b. is c. != d. in
Q8. Which function is used to take user input in Python 3?
a. input() b. raw_input() c. read() d. scanf()
Q9. Which of the following is NOT a comparison operator?
a. >= b. != c. <> d. <
Q10. Which of the following keywords is used to create a decision-making structure in Python?
a. loop b. condition c. if d. decide

Part B: Fill in the Blanks


Q11. The operator ** is used for _______________.
Q12. Python ignores a line if it starts with ______________.
Q13. The result of 10 % 3 is ______________.
Q14. The if block is followed by the __________ block for alternate execution.
Q15. The logical operator used to invert a condition is ___________.
Q16. Python uses ____________ to indicate a block of code under a condition.
Q17. The default data type returned by input() is ___________.
Q18. The operator used to compare if two values are not equal is __________.
Q19. print() is an example of a ____________ function.
Q20. Python was created by ____________ van Rossum.

Part C: True/False
Q21. // is used to perform floating point division.
Q22. A variable in Python can start with a digit.
Q23. The keyword elif is short for "else if".
Q24. Logical AND is represented by && in Python.
Q25. Python is an interpreted language.
Q26. Python is not case sensitive.
Q27. input() always returns data in string format.
Q28. The not operator can be used with Boolean values only.
Q29. Python supports both single and double quotes for strings.
Q30. Every if must have an else in Python.

Part D: Predict the Output


Q31. print(10 // 3)
Q32.a = 7
b=2
print(a % b)
Q33.
x=5
print(x == 5 and x != 10)
Q34. x=3
y=2
print(x ** y)

Q35.print(10 + 5 * 2 - 3)
Q36. a, b, c = 4, 2, 1
print((a + b) * c)

Q37. name = "John"


print(name == "john")
Q38. print(not False)
Q39. x = 3
if x % 2 == 0:
print("Even")
else:
print("Odd")
Q40. a = 10
b=5
if a > b:
print("a is greater")

Part E: Error Finding


Each question has 4 errors. Identify and correct them.

Q41. x = 10
if x => 5
print("Greater")
else:
print("Smaller")

Q42. num = input("Enter number")


if num % 2 = 0:
print("Even")
else
print("Odd")
Q43. a=3
b == 5
if a * b == 15
print("Correct")
else:
print("Wrong")
Q44. x=7
if x > 10
print("Big")
elif x < 3:
print("Small")
else:
print("Medium")
Q45. a=5
b=2
c = a // b
print c

Part F: Write Python Programs


Q46. Write a program to input a number and print whether it is positive, negative, or zero.
Q47. Write a program to check whether a number is even or odd.
Q48. Write a program that accepts two numbers and prints the greater number.
Q49. Write a Python program to take user input and calculate square and cube of the number.
Q50. Write a Python program to swap values of two variables using a third variable.
Q51. Write a Python program to calculate the result of a + b * c - d / e and show operator precedence.
Q52. Write a program to find whether a number is divisible by both 5 and 7.
Q53. Write a program to check if a number is between 10 and 50.
Q54. Write a program that prints "Pass" if marks are >= 33, else "Fail".
Q55. Write a program to categorize marks:
90–100: Outstanding
75–89: Excellent
60–74: Good
Below 60: Needs Improvement

You might also like