File
File
File
function Indexing().
def indexing():
a2=[12,'hello',26,53]
for x in range (len(a2)-1,-1,-1):
if x==1:
for y in range (len(a2[x])-1,-1,-1):
print(a2[x][y])
else:
print(a2[x])
indexing()
# 2 question : Write a program to demonstrate tuple and dictionary using for loop.
a2={1:(12,43,53),2:(22,"four",21)}
for x in a2.values():
for y in x:
print(y)
a=0
while 10>a:
if a<5:
print(a)
elif a==5:
print(a*a)
a=a+1
continue
elif a>5 and a<9:
print("remaining is :",a)
else:
break
a=a+1
# 5 question : Write a program to read a string from user input and tell the no. of
uppercase and lowercase letters.
def readstring():
a1=input('enter upper and lower case text :\n')
upper=lower=0
for i in a1:
if i.isupper():
upper+=1
else:
lower+=1
print('no. of uppercase :',upper,
'\n','no. of lowercase :',lower)
readstring()
def Factorial():
a1=int(input('Enter the no. :'))
s=1
for x in range (a1,0,-1):
s=s*x
Factorial()
def s1():
global w1
w1=50
print("local keyword :",w1)
w1=5
print("global keyword :",w1)
s1()
def var_len_arg(a,*b):
print('simple argument :',a)
print('variable length argument :',b)
var_len_arg(3,'hello',62,43535,[43,565])
def retu():
b=0
a=[]
while 30>b:
if b>15:
return a
else:
a.append(b)
b+=2
s1=retu()
print(s1)
# 9 question : Write a program which take integer from user and print all the
numbers separtally .
for x in s1:
print(x,end=' ')
def write_txt():
a1=open("read_file.txt",'w+')
print(a1.read())
yes='y'
while yes=='y':
d1=input('enter name :')
d2=input('enter roll no. :')
d3=input('enter class :')
t=[d1,d2,d3]
a1.write('hrllo')
yes=input('y/n :')
print(a1.read())
a1.close()
write_txt()
def read_txt():
a1=open("read_file.txt",'r')
k=a1.read()
print(k)
a1.close()
read_txt()
def write_bin():
with open('rt.bin','wb') as f:
dump('hello',f)
write_bin()
read_bin()
def write_csv():
with open(r"C:\ft.csv",'w') as f:
w1=writer(f)
w1.writerow([54,56,5,65,'hello'])
write_csv()
def read_csv():
with open(r"C:\ft.csv",'r') as f:
r=reader(f)
for x in r:
print(x)
read_csv()
stack()
# 18 write a program which remove data from stack until overflow of stack.
def remov():
a=[34,3,4]
for x in range (len(a)+1):
if a==[]:
print('stack overflow ')
else:
print('removing ',a.pop(-1))
remov()
def read_stack():
a=[23,62,53,26]
if a==[]:
print('stack overflow')
else:
print('the top element is :',a[-1])
read_stack()
# 22 question : write a program which demonstrate the use of show and create and
drop command in SQL.
show databases;
use office;
# 24 question : write a command which describes the table "year2022" and operte
following opertaions.
a) drop { phone_no }
b) change { name_workers to emp_name }
c) modify address { not null }
d) rename table { office to office_2022 }
e) add column { age - not null int }
f) delete a table
use school;