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

Class 12 CS 50 Important QA Python SQL Programs

The document contains 50 important viva questions and answers related to Python and computer science concepts, including data structures, file handling, and database management. It also includes 20 practical Python programs demonstrating various functionalities such as arithmetic operations, string manipulation, file operations, and database interactions. The content is aimed at Class 12 Computer Science students under the CBSE curriculum.

Uploaded by

shwetalahoriji
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)
16 views4 pages

Class 12 CS 50 Important QA Python SQL Programs

The document contains 50 important viva questions and answers related to Python and computer science concepts, including data structures, file handling, and database management. It also includes 20 practical Python programs demonstrating various functionalities such as arithmetic operations, string manipulation, file operations, and database interactions. The content is aimed at Class 12 Computer Science students under the CBSE curriculum.

Uploaded by

shwetalahoriji
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

Class 12 Computer Science (CBSE)

50 Important Viva Questions with Answers + Python Practical Programs

Q1. What is Python?


Ans: Python is a high-level, interpreted, object-oriented programming language.
Q2. Name two features of Python.
Ans: Simple syntax and platform independent.
Q3. What is a variable?
Ans: A variable is a named memory location used to store data.
Q4. Difference between list and tuple.
Ans: List is mutable, tuple is immutable.
Q5. What is a dictionary?
Ans: Dictionary stores data in key-value pairs.
Q6. What is file handling?
Ans: File handling is used to store data permanently in files.
Q7. Difference between read() and readline().
Ans: read() reads full file, readline() reads one line.
Q8. What is exception handling?
Ans: It handles runtime errors using try-except blocks.
Q9. What is a function?
Ans: A function is a block of reusable code.
Q10. What is recursion?
Ans: A function calling itself is called recursion.
Q11. What is DBMS?
Ans: DBMS is software used to manage databases.
Q12. What is RDBMS?
Ans: RDBMS stores data in tables with relations.
Q13. What is a table?
Ans: Table stores data in rows and columns.
Q14. What is primary key?
Ans: Primary key uniquely identifies a record.
Q15. What is foreign key?
Ans: Foreign key links two tables.
Q16. What is normalization?
Ans: Process of reducing data redundancy.
Q17. What is SQL?
Ans: SQL is Structured Query Language.
Q18. What is SELECT command?
Ans: Used to fetch data from table.
Q19. What is WHERE clause?
Ans: Used to apply condition.
Q20. Difference between DELETE and DROP.
Ans: DELETE removes records, DROP deletes table.
Q21. What is UPDATE command?
Ans: Used to modify records.
Q22. What is ORDER BY?
Ans: Sorts records.
Q23. What is GROUP BY?
Ans: Groups records.
Q24. What is aggregate function?
Ans: Function that performs calculation on data.
Q25. Name aggregate functions.
Ans: SUM, AVG, COUNT, MAX, MIN.
Q26. What is MySQL?
Ans: MySQL is an RDBMS.
Q27. What is cursor?
Ans: Cursor executes SQL commands.
Q28. What is commit()?
Ans: Saves changes permanently.
Q29. What is fetchone()?
Ans: Fetches one record.
Q30. What is fetchall()?
Ans: Fetches all records.
20 Important Python Practical Programs
Program to add two numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum =", a + b)

Program to check even or odd


n = int(input("Enter number: "))
if n % 2 == 0:
print("Even")
else:
print("Odd")

Program to find factorial


n = int(input("Enter number: "))
fact = 1
for i in range(1, n+1):
fact *= i
print("Factorial =", fact)

Program to check palindrome


s = input("Enter string: ")
if s == s[::-1]:
print("Palindrome")
else:
print("Not Palindrome")

Program to count vowels


s = input("Enter string: ")
count = 0
for ch in s:
if [Link]() in 'aeiou':
count += 1
print("Vowels =", count)

Program to write data into file


f = open("[Link]", "w")
[Link]("Welcome to Class 12")
[Link]()

Program to read data from file


f = open("[Link]", "r")
print([Link]())
[Link]()

Program using function


def add(a, b):
return a + b
print(add(5, 3))

Program using recursion


def fact(n):
if n == 0:
return 1
else:
return n * fact(n-1)
print(fact(5))

Program to search element in list


lst = [10, 20, 30, 40]
x = int(input("Enter element: "))
if x in lst:
print("Found")
else:
print("Not Found")

Program to create dictionary


d = {"Roll":1, "Name":"Amit"}
print(d)

Program to connect Python with MySQL


import [Link]
con = [Link](host="localhost", user="root", password="root", database="school")
cur = [Link]()
[Link]("SELECT * FROM student")
for row in cur:
print(row)
[Link]()

Program to insert record using MySQL


[Link]("INSERT INTO student VALUES (1,'Amit',90)")
[Link]()

Program to update record


[Link]("UPDATE student SET marks=95 WHERE roll=1")
[Link]()

Program to delete record


[Link]("DELETE FROM student WHERE roll=1")
[Link]()

Program to use fetchone()


[Link]("SELECT * FROM student")
print([Link]())

Program to use fetchall()


[Link]("SELECT * FROM student")
print([Link]())

Program to count list elements


lst = [1,2,3,4,5]
print(len(lst))

Program to sort list


lst = [4,2,1,3]
[Link]()
print(lst)

Program to find largest number


a = int(input("Enter a: "))
b = int(input("Enter b: "))
c = int(input("Enter c: "))
print(max(a,b,c))

You might also like