0% found this document useful (0 votes)
10 views4 pages

08 A 71

The document is an assignment for Class XI Computer Science at Amity International School, focusing on Python programming concepts. It includes multiple choice questions (MCQs) and competency-based questions (CBQs) covering various Python topics such as functions, loops, and data types. Additionally, it provides programming practice problems related to series generation, Armstrong numbers, prime numbers, perfect numbers, and grade calculation based on marks.

Uploaded by

manya.mangal123
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)
10 views4 pages

08 A 71

The document is an assignment for Class XI Computer Science at Amity International School, focusing on Python programming concepts. It includes multiple choice questions (MCQs) and competency-based questions (CBQs) covering various Python topics such as functions, loops, and data types. Additionally, it provides programming practice problems related to series generation, Armstrong numbers, prime numbers, perfect numbers, and grade calculation based on marks.

Uploaded by

manya.mangal123
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/ 4

AMITY INTERNATIONAL SCHOOL, PUSHP VIHAR

ASSIGNMENT – 2
CHAPTER 3, 4 AND 5: PYTHON PROGRAMMING CONCEPTS
Subject: Computer Science
Class: XI
Multiple Choice Questions(MCQ):
1. Which keyword is used to define a function in Python?
a) func b) define
c) def d) function
2. What is the output of the following code?

a) 20 b) 14
c) 24 d) 18
3. Which of the following is not a valid Python data type?
a) list b) tuple
c) array d) set
4. Which of the following is a valid variable name in Python?
a) 1variable b) variable_1
c) variable-1 d) variable 1
5. What will be the output of: print(type(3.14))
a) <class 'float'> b) <type 'float'>
c) float d) 3.14
6. Which operator is used for exponentiation in Python?
a) ^ b) **
c) // d) %
7. What does the input() function do?
a) Terminates the program b) Takes user input
c) Outputs data to the screen d) Creates a variable
8. Which of the following is used to write a comment in Python?
a) // b) <!-- -->
c) # d) /* */
9. Which of the following will raise a ZeroDivisionError?
a) 10/2 b) 10//3
c) 5/0 d) 0/5
10. Which of the following is the correct syntax for an if statement in Python.
a) if x > y then: b) if (x > y):
c) if x > y: d) if x > y then do:
11. How many times will the loop run?
for i in range(3):
print(i)
a) 0 b) 2
c) 3 d) 4
12. What is the output of the following code?
for i in range(5):
if i == 3:
break
print(i)
a) 0 1 2 3 4 b) 0 1 2
c) 0 1 2 3 d) 1 2 3
13. Which statement will skip the current iteration in a loop and continue with the next one?
a) break b) skip
c) pass d) continue

14. What happens if break is used outside a loop?

a) Causes a syntax error b) Program exits


c) Skips execution d) Does nothing

15. Which of the following evaluates to True in Python?

a) 0 == False b) [] == False
c) None == False d) " " == True

Competency Based Questions (CBQ):


1. What is the output of the following code segment:
a) for i in range(2, 10, 3):
print(i, end=" ")

b) for i in range(4):
if i == 2:
pass
print(i)

c) x = 4
if x % 2 == 0:
if x % 3 == 0:
print("Divisible by 6")
else:
print("Even but not by 3")
else:
print("Odd")
d) for i in range(1, 6):
if i == 4:
continue
print(i, end=" ")

e) for i in range(1, 4):


for j in range(1, i):
print(j, end=" ")
print()

2. How many times loop executes?


a) count = 0
for i in range(5):
count += 1
print(count)

b) i = 1
while i < 6:
print(i)
i += 2

3. Convert following while loop into for and vice versa without changing the output?
a)
i=2
while i < 10:
print(i)
i += 2

b)
for i in range(10, 0, -3):
print(i)

4. Identify valid/invalid identifier. Give reason for incorrect identifier:

Break : _______________________________ _total: __________________________

for: ________________________________ 23total: __________________________

5. Find error(s) in following code segment:

a) s = "HELLO"

i = =0

while i < len(s)

print(s(i))

i =+ 1

b) x = 10
if x > 5

Print("Greater")
elseif x == 5:

print("Equal")

Else:

print("Smaller")

Programming Practice:

Q1. Write a program to generate this series (n terms):

Q2. Write a program to print whether number entered is Armstrong number or not.
Hint : An Armstrong number (also called a narcissistic number, pluperfect digital invariant (PPDI), or pluperfect number) is a
number that is equal to the sum of its own digits raised to the power of the number of digits.

Q3. Write a program to print whether number entered is prime number or not.

Q4. Write a program to print whether number entered is perfect number or not.

Q5. Write a program to input marks and print Grade as per rules:
 90 and above → Grade A
 75–89 → Grade B
 50–74 → Grade C
 Below 50 → Grade D

You might also like