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

Python Programming Full Solved QA BCA Final

The document provides a comprehensive overview of Python programming concepts, including definitions and examples of lists, tuples, functions, loops, exception handling, dictionaries, and file handling. It also includes practical programming exercises such as checking for prime numbers, calculating factorials, and generating Fibonacci series. Additionally, it explains the concepts of classes and objects, as well as the use of break statements in loops.

Uploaded by

rathorekabit
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)
8 views4 pages

Python Programming Full Solved QA BCA Final

The document provides a comprehensive overview of Python programming concepts, including definitions and examples of lists, tuples, functions, loops, exception handling, dictionaries, and file handling. It also includes practical programming exercises such as checking for prime numbers, calculating factorials, and generating Fibonacci series. Additionally, it explains the concepts of classes and objects, as well as the use of break statements in loops.

Uploaded by

rathorekabit
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 Programming - Full Solved Questions (BCA

Final Year)
Q1. Python kya hai?
Python ek high-level, interpreted, object-oriented aur general-purpose programming language hai.
Iska syntax simple aur readable hota hai, isliye beginners ke liye bahut popular hai.
Python ka use web development, data science, AI, automation aur scripting me hota hai.

Q2. Python me comment kaise likhte hain?


Python me comments code ko explain karne ke liye use hote hain.

Types:
1. Single line comment → # se likhte hain
Example: # This is a comment

2. Multi-line comment → triple quotes se


Example:
'''
Multi-line comment
'''

Q3. List kya hoti hai?


List Python ka ek ordered aur mutable collection hoti hai. Isme different data types store kiye ja
sakte hain.

Features:
- Ordered hoti hai
- Mutable (change ho sakti hai)
- Duplicate values allowed

Example:
my_list = [10, 20, 30]
print(my_list)

Q4. Tuple kya hai?


Tuple ek ordered lekin immutable collection hota hai. Isme values change nahi ki ja sakti.

Features:
- Ordered
- Immutable
- Faster than list

Example:
t = (1, 2, 3)
print(t)

Q5. List aur Tuple me antar likhiye.


List:
- Mutable hoti hai
- Square brackets [] use hote hain
- Slower than tuple
Tuple:
- Immutable hota hai
- Parentheses () use hote hain
- Faster hota hai

Q6. Function kya hota hai?


Function code ka reusable block hota hai jo ek specific task perform karta hai.

Syntax:
def function_name():
statements

Example:
def greet():
print("Hello")

greet()

Q7. Python me loop ke prakar likhiye.


Python me mainly do prakar ke loops hote hain:

1. for loop → fixed iteration ke liye


Example:
for i in range(5):
print(i)

2. while loop → condition true hone tak


Example:
i=1
while i <= 5:
print(i)
i += 1

Q8. Exception handling kya hai?


Program run ke time jo errors aate hain unhe handle karne ki technique ko exception handling
kehte hain.

Keywords:
- try
- except
- finally

Example:
try:
x = 10/0
except ZeroDivisionError:
print("Error aayi")

Q9. Dictionary kya hai?


Dictionary ek unordered collection hai jo key-value pair me data store karti hai.

Features:
- Key unique hoti hai
- Mutable hoti hai

Example:
student = {"name": "Ram", "age": 20}
print(student["name"])

Q10. File handling kya hai?


File handling ka use file ko create, read, write aur close karne ke liye hota hai.

Modes:
- r → read
- w → write
- a → append

Example:
f = open("[Link]", "w")
[Link]("Hello")
[Link]()

Q11. Prime number check karne ka Python program likhiye.


num = int(input("Enter number: "))

if num > 1:
for i in range(2, num):
if num % i == 0:
print("Not Prime")
break
else:
print("Prime")
else:
print("Not Prime")

Q12. Factorial ka program likhiye.


n = int(input("Enter number: "))
fact = 1

for i in range(1, n+1):


fact = fact * i

print("Factorial =", fact)

Q13. Fibonacci series ka program likhiye.


n = int(input("Enter terms: "))
a, b = 0, 1

for i in range(n):
print(a)
a, b = b, a+b

Q14. Class aur Object kya hai?


Class ek blueprint hoti hai jisme properties aur methods define hote hain.
Object class ka instance hota hai.

Example:
class Student:
def __init__(self, name):
[Link] = name

s1 = Student("Ram")
print([Link])

Q15. break statement ka use kya hai?


break statement loop ko turant terminate kar deta hai.

Example:
for i in range(10):
if i == 5:
break
print(i)

You might also like