Computer Science
Computer Science
PROJECT
PyThON & SQL
• NAME :- ShAIL.A.PATEL
• CLASS :- 11 SCI
Th
• ROLL :- 29
FILE RECORD
(PyThON)
• Programme :
Q. Accept a number and reverse it.
n = int(input('Enter
= 10*rev + r print(rev)
Q. Accept a number and and print the sum of its digit in single digit.
#Code:
n = int(input('Enter number:'))
while n > 9: s = 0
n = n//10 s += r n
= s
print(n)
n = int(input('Enter number:'))
c=ns=0
while n > 0:
r = n%10
n = n//10
s = r**3+s if s == c:
print('It is an Armstrong')
else:
male/female>>>>>')
format >'))
if b=='male': if c<=12.00:
c>=12.00:
print('Good Morning',a,'madam')
else: print('Good
Afternoon',a,'madam')
Q. Accept name, roll number and marks of subjects and print its result.
mkseng=float(input('Enter your
english marks:'))
marks:'))
mkssci=float(input('Enter your science
marks:'))
studies marks:'))
Technology marks:'))
mt=(meng+mmat+msci+mss+mit)/5
if mt>=91:
print('Total Percentage-',mt,'Grade-A1')
elif mt>=81:
print('Total percentage-',mt,'Grade-A2')
elif mt>=71:
print('Total percentage-',mt,'Grade-B1')
elif mt>=61:
print('Total percentage-',mt,'Grade-B2')
else:
print('Total percentage-',mt,'Grade-E')
2):
import math as m
x=m.fabs(m.sqrt((a+
m.exp(e,2)/(5+m.log(30)))))
print(x)
STRING
Q. Accept a string and check how many times the letter ‘A’ exist.
#Code:
s=input('Enter your string:
range(l): if s[i]=='A':
c=c+1 print(c)
Q. Accept a string and the number of vowels present in the string.
range(l): if s[i] in
['A','E','I','O','U','a','e','i','o','u']:
c=c+1
print(c)
Q. Write a code to find the position of first occurrence of a letter in given string.
S=input("Enter a string:-")
ch=input("Enter the character to find:-")
i=0
for i in range(len(S)):
if S[i]==ch:
print(i+1) break
else:
print("Character not found")
Q. Accept a String/Paragraph and a character and find how many times this character
exist in the String/Paragraph.
s = input("Enter string: ")
x = input("Enter character: ")
c=0
for i in s:
if x == i:
c += 1 if c != 1:
print(x, "exist", c, "times")
else:
print(x, "doesn’t exist")
Q. Accept a String/Paragraph and a character and remove that character in the
String/Paragraph.
s = input("Enter string: ") c
= '' for i in s: if i !=
c: x += i print(x)
if S == S[::-1]:
print("It is Palindrome")
else: print("It is not
Palindrome")
if S == S[::-1]:
print("It is Palindrome")
else: print("It is not
Palindrome")
PATTERN PRINTING
#Pattern 1:
for r in range(1,5):
for c in range(1,5):
Output:
* * * *
* * * *
* * * *
* * * *
#Pattern 2:
for r in range(1,5): for c
in range(1,r+1):
Output:
*
* *
* * *
* * * *
#Pattern 3:(Decreasing Triangle)
for r in range(1,5): for c
in range(r,5):
Output:
****
***
**
range(r,4): print('
range(r):
in range(r+1):
Output:
*
* * *
* * * * *
NUMBER PATTERN
#Pattern 1:
for r in range(1,5): for c
in range(1,r+1):
Output:
1
1 1
1 1 1
1 1 1 1
#Pattern 2:
for r in range(1,5): for c
in range(1,r+1):
Output:
1
1 2
1 2 3
1 2 3 4
#Pattern 3:
for r in range(4,0,-1): for
c in range(1,r+1):
print(c,end=" ") print()
Output:
1 2 3 4
1 2 3
1 2
#Pattern 4:
for r in range(1,5): for c in
range(1,5-r): print("
range(1,r+1):
range(r-1,0,-1):
Output:
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
#Pattern 5:
r = int(input('Enter number of rows required: '))
end='')
for j in range(2*i+1):
print('1',end='') else:
Table: Dpt
dpno Dnm floor
1 acc 2
2 edp 3
3 pkg 1
4 sales 4
Queries:
Q. Display total number of employes working in account department.
Ans: Select count(enm) from emp where dpno = (select dpno from
Q. Find maximum and minimum salary of each department wise along with their names.
Q. Display all the employees name whose salary is less than 20,000 whose name starts with ‘A’.
Ans: Select enm from emp where sal<500 and
is null:
and dnm!='edp';
Q. Dispaly employees name,department number and floor in which ‘a’ character is exist in the
department name.
Q. Display department name and their expenses of salary in highest to lowest order.
sum(sal);