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

Python and MySQL Practical Questions

The document contains practical programming questions and answers for Python and MySQL. It includes basic tasks such as calculating sums, checking even/odd numbers, and managing a database with operations like creating tables and inserting records. Each question is followed by a concise code solution demonstrating the required functionality.

Uploaded by

bruhplsbra
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)
2 views3 pages

Python and MySQL Practical Questions

The document contains practical programming questions and answers for Python and MySQL. It includes basic tasks such as calculating sums, checking even/odd numbers, and managing a database with operations like creating tables and inserting records. Each question is followed by a concise code solution demonstrating the required functionality.

Uploaded by

bruhplsbra
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 Practical Questions

Q1. Write a program to input two numbers and print their sum.
Ans: a = int(input('Enter first: ')); b = int(input('Enter second: ')); print('Sum =', a+b)
Q2. Write a program to check whether a number is even or odd.
Ans: n = int(input('Enter: ')); print('Even' if n%2==0 else 'Odd')
Q3. Write a program to print factorial of a number.
Ans: n=int(input('Enter: ')); fact=1; for i in range(1,n+1): fact*=i; print('Factorial=',fact)
Q4. Write a program to check if a number is prime.
Ans: n=int(input('Enter: ')); flag=True; for i in range(2,n): if n%i==0: flag=False; break
print('Prime' if flag else 'Not Prime')
Q5. Write a program to display Fibonacci series up to n terms.
Ans: n=int(input('Enter terms: ')); a,b=0,1 for i in range(n): print(a,end=' '); a,b=b,a+b
Q6. Write a program to check palindrome string.
Ans: s=input('Enter string: ') print('Palindrome' if s==s[::-1] else 'Not Palindrome')
MySQL Practical Questions
Q1. Create a database named School.
Ans: CREATE DATABASE School;
Q2. Create a table Student with (id, name, class, marks).
Ans: CREATE TABLE Student(id INT PRIMARY KEY, name VARCHAR(30), class INT, marks INT);
Q3. Insert 3 records into Student table.
Ans: INSERT INTO Student VALUES(1,'Amit',11,87); INSERT INTO Student VALUES(2,'Riya',11,92);
INSERT INTO Student VALUES(3,'Kabir',10,78);
Q4. Show all records of Student table.
Ans: SELECT * FROM Student;
Q5. Update marks of student with id=2.
Ans: UPDATE Student SET marks=95 WHERE id=2;
Q6. Delete record of student with id=3.
Ans: DELETE FROM Student WHERE id=3;
Q7. Show structure of Student table.
Ans: DESCRIBE Student;
Q8. Display names starting with 'R'.
Ans: SELECT name FROM Student WHERE name LIKE 'R%';
Q9. Add a new column age to Student table.
Ans: ALTER TABLE Student ADD age INT;
Q10. Drop Student table.
Ans: DROP TABLE Student;
bsdk jeele apni jindagi

You might also like