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

Class 11 Computer Science Python Questions

Uploaded by

ahmad7902938
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)
4 views2 pages

Class 11 Computer Science Python Questions

Uploaded by

ahmad7902938
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
You are on page 1/ 2

Class 11 Computer Science (Python) - Important Questions and Answers

Q: What are the key features of Python?

A: 1. Easy to learn

2. Interpreted language

3. Dynamically typed

4. Platform independent

5. Extensive libraries

Q: Explain the difference between a compiler and an interpreter.

A: Compiler translates the entire code at once; Interpreter translates code line-by-line.

Q: What are Python keywords? List any five with examples.

A: Keywords are reserved words in Python. Examples: if, else, while, def, return.

Q: Explain the different types of operators in Python with examples.

A: 1. Arithmetic (+, -, *, /, %, **)

2. Relational (==, !=, >, <)

3. Logical (and, or, not)

4. Assignment (=, +=, -=)

Q: What is the difference between 'is' and '==' operator?

A: 'is' compares object identity, '==' compares values.

Q: Write a Python program to print the sum of the first 10 natural numbers using a while

loop.

A: sum = 0

i=1

while i <= 10:

sum += i

i += 1

print('Sum:', sum)

Q: What is the difference between break, continue, and pass?


A: break - exits loop

continue - skips current iteration

pass - does nothing

Q: Write a Python function to find the factorial of a number using recursion.

A: def factorial(n):

if n == 0:

return 1

else:

return n * factorial(n-1)

Q: What is the difference between append() and extend() in a list?

A: append() adds an element to the end, extend() adds elements from an iterable.

Q: Write a program to add and update key-value pairs in a dictionary.

A: d = {'a': 1, 'b': 2}

d['c'] = 3

d['a'] = 10

print(d)

Q: Write a Python program to handle division by zero exception.

A: try:

x = 10 / 0

except ZeroDivisionError:

print('Cannot divide by zero')

Q: Explain the use of the math module in Python with examples.

A: import math

print([Link](16))

print([Link](2, 3))

You might also like