Python MySQL Expanded Assignment
Python MySQL Expanded Assignment
Class: 12th
Date of Submission:
Table of Contents
1. Python Basics
2. MySQL Commands
3. Python-MySQL Connectivity
6. Conclusion
Python and MySQL for Class 12 Computer Science
Code:
def factorial(n):
if n == 0:
return 1
return n * factorial(n - 1)
Output:
Factorial of 5: 120
Code:
def is_prime(num):
if num <= 1:
return False
if num % i == 0:
Python and MySQL for Class 12 Computer Science
return False
return True
Output:
7 is prime: True
Code:
total = sum(numbers)
Output:
4. Fibonacci Series:
Code:
def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
fibonacci(10)
Python and MySQL for Class 12 Computer Science
Output:
0 1 1 2 3 5 8 13 21 34
5. Reverse a String:
Code:
def reverse_string(s):
return s[::-1]
print(reverse_string("hello"))
Output:
olleh
6. Palindrome Checker:
Code:
def is_palindrome(s):
return s == s[::-1]
Output:
1. Join Tables:
FROM students
2. Group By:
FROM students
GROUP BY grade;
3. Order By:
Code:
1. Create Database:
2. Insert Data:
4. Update Data:
Conclusion