0% found this document useful (0 votes)
478 views10 pages

Phython Code For School Projects Class 12th Cbse

The document provides a comprehensive guide on various Python programming tasks, including calculating percentages, averages, simple and compound interest, and generating patterns like Fibonacci series and triangles. It also covers basic MySQL commands for managing databases, such as creating tables, modifying columns, and deleting data. Each section includes example code snippets to illustrate the concepts discussed.

Uploaded by

prabh.noor2430
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)
478 views10 pages

Phython Code For School Projects Class 12th Cbse

The document provides a comprehensive guide on various Python programming tasks, including calculating percentages, averages, simple and compound interest, and generating patterns like Fibonacci series and triangles. It also covers basic MySQL commands for managing databases, such as creating tables, modifying columns, and deleting data. Each section includes example code snippets to illustrate the concepts discussed.

Uploaded by

prabh.noor2430
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

INDEX

 Python:
 Introduction to Python
 To find %age and avg. grade for given marks
 To find price of an item after discount
 To find LSA, TSA and Volume of a cube/cuboid
 To find Simple Interest and Compound Interest
 To print the elements of a given list in reverse order
 To find the number of vowels in a word
 To find the sum of squares till given natural numbers
 To print the first n multiples of a number
 To find profit-loss on a given cost and sell price
 To find Fibonacci series till n numbers
 Patterns
i. Pyramid
ii. Right Triangle
iii. Diamond
iv. Floyd’s Triangle

 MySQL

2
# To find %age and avg. grade for given marks
This program will find out if the user passed, and then give their percentage, and
average grade using the system :
A+ grade for 95% and above
A grade for 90% and above
B+ grade for 80% and above
B grade for 75% and above
C grade for 55% and above
D grade for 33% and above
F grade for 33% and below

Program:
phy = int(input("Enter your marks scored in physics: "))
chem = int(input("Enter your marks scored in chemistry: "))
math = int(input("Enter your marks scored in mathematics: "))
eng = int(input("Enter your marks scored in english: "))
ip = int(input("Enter your marks scored in IP: " ))
print()
total = phy + chem + math + eng + ip
percentage = (total/500)*100

print("Results:")
if percentage < 33:
print("Opps! You Failed, Better Luck Next Time\n")
elif percentage >= 33:

4
# To find price of an item after discount
This program will help the user to find the final price of a product after
the discount is added.

Program:
mrp = int(input("Enter the MPR of the product"))
dis = int(input("Enter the percentage of dicount on the product"))
fin = mrp*(dis/100)
print("Final price of your product: ", mrp - fin)

Output:

6
# To find Simple Interest and Compound Interest
This program helps the user to fin the amount of simple interest and
compound interest for their respective amounts after a fixed number of years.

Code:
p = float(input("Enter the Principal Amount: "))
r = float(input("Enter the Rate of interest per years: "))
t = float(input("Enter the Time period in years: "))

si = (p*r*t)/100
ci = (p*(1+(r/100))**t)-p

print("Simple interest: ", si)


print("compound interest: ",round(ci, 2))

Output:

8
# To find the number of vowels in a word
This program helps in finding the number of vowels in a word.

Code:

word = input("Enter your word: ")


v = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
vcount = 0
for i in word:
if i in v:
vcount += 1

print(vcount)

Output:

10
#To print the first n multiples of a number
With this program, u can find the first n multiples of any number inputted by
the user

Code:
n = int(input("Enter the number: "))
for i in range(1, n+1):
print(n*i, end=" ")

Output:

12
#To Find Fibonacci series till n numbers
Code:
n = int(input("Enter the number of terms: "))
a, b = 0, 1
for i in range(n):
print(a, end=" ")
a, b = b, a + b
Output:

14
Diamond

rows = int(input("Enter the number of rows"))


for i in range (1, rows+1):
print(" " *(rows - i), end = " ")
print("*" *(2*i-1))
for j in range (rows+1, 0, -1):
print(" " *(rows - j), end = " ")
print("*" *(2*j-1))

Floyd’s Triangle

rows = int(input("Enter the number of rows"))


n=1
for i in range(1, rows+1):
for j in range(1, i+1):
print(n, end=" ")
n += 1
print()

16
smarks_eng int, smarks_ip int, smarks_grade char(1),
smarks_pcent decimal);

Showing All the tables in a database:


SHOW TABLES;

Adding a primary key after creating a table:


ALTER TABLE STUDENTS ADD PRIMARY KEY (adm_no);

Modifying a column in the table:


ALTER TABLE STUDENTS MODIFY smarks_grade char(2);

Entering data into the table:

18
SELECT adm_no, sname, smarks_grade FROM STUDENTS
WHERE sclass >= 11;

Deleting data from a table:


DELETE FROM STUDENTS;

Deleting a table:
DROP TABLE STUDENTS;

Deleting A Database:
DROP DATABASE myDB;

20

You might also like