Skip to content

Instantly share code, notes, and snippets.

@TreavVasu
Created January 26, 2018 20:47
Show Gist options
  • Select an option

  • Save TreavVasu/0efa4c21cd30378fb4dd8bbfe667cf86 to your computer and use it in GitHub Desktop.

Select an option

Save TreavVasu/0efa4c21cd30378fb4dd8bbfe667cf86 to your computer and use it in GitHub Desktop.
School Qs
def Q(l):
for c in range(0,len(l)):
for k in range(0,len(l)-c):
print l[k],
print "0 "*c
x=eval(raw_input("L:"))
Q(x)
class stud:
def __init__(self):
self.Adno=0
self.name=''
self.percentage=0.0
self.stream=''
self.fees=0.0
def Read_data(self):
self.Adno=input("Adno:")
self.name=raw_input("Name:")
self.percentage=float(raw_input("per: "))
self.Choose_stream()
def Choose_stream(self):
if self.percentage>=90.0:
self.stream="computer"
self.fees=18000
elif self.percentage>=80.0 and self.percentage<90.0:
self.stream="Bio"
self.fees=14000
else:
self.stream="Commerce"
self.fees=12000
self.Display_data()
def Display_data(self):
print self.Adno
print self.name
print self.percentage
print self.stream
print self.fees
x=stud()
x.Read_data()
class stud:
def __init__(self):
self.total_Amt=0.0
self.Book_name=''
self.price=0.0
self.Qty=0
def input(self):
self.Qty=input("Qty:")
self.Book_name=raw_input("Book_name:")
self.price=float(raw_input("Price: "))
self.Total_cost()
def Total_cost(self):
self.total_Amt=self.Qty*self.price
self.Output()
def Output(self):
print self.Qty
print self.Book_name
print self.price
print self.total_Amt
x=stud()
x.input()
def Q(n):
for c in range(2,n+1):
k=0
for r in range(2,(c/2)+1):
if c%r==0:
k=1
break
if k==0:
print c ,"is prime"
x=input("Prime upto:")
# print
Q(x)
##def Qw():
## for i in range(2,n+1):
## s=0
## for r in range(2,i):
## if i%r==0:
## s+=1
## if s==0:
## print i
##n=input("Upto:")
##Qw()
def Q17(L):
x=len(L)-1
M=[]
for c in range(0,x):
if c==0:
M.append(L[x])
M.append(L[c])
print M
x=eval(raw_input("List:"))
Q17(x)
def Q18(x):
M=[]
for c in range(len(x)-1,-1,-1):
M.append(x[c])
print M
x=eval(raw_input("List:"))
Q18(x)
def Q19(L):
for c in range(0,len(L)):
if L[c]%2==0:
L[c]*=2
else:
L[c]*=3
print L
x=eval(raw_input("List:"))
Q19(x)
def Q20(x):
v=len(x)
for c in range(0,v):
for k in range(0,c+1):
print x[k],
print "0 "*(v-c-1)
x=eval(raw_input("List:"))
Q20(x)
op=open("source.txt","r")
tp=open("target.txt","w")
s=' '
while s:
s=op.readline()
if s!="":
if s[0]=="@":
pass
else:
tp.write(s)
op.close()
tp.close()
import os
op=open("Result.dat","rb")
tp=open("temp.dat","wb")
s=' '
c=1
while s:
s=op.readline()
if c==3:
pass
else:
tp.write(s)
c+=1
op.close()
tp.close()
os.remove("Result.dat")
os.rename("temp.dat","Result.dat")
def 16(N):
def Q(N):
s=0
if N>0:
for c in range(N,2*N+1):
s+=c
else:
k=-N
for c in range(k,2*k+1):
s+=c
s=-s
print s
x=input("N::")
Q(x)
def Q2(N,M):
if len(N)!=len(M):
print "Insane"
else:
L=[0]*(len(N))
for c in range(0,len(N)):
L[c]=N[c]+M[c]
print L
x=eval(raw_input("List1:"))
y=eval(raw_input("List2:"))
Q2(x,y)
def Q17(L):
x=len(L)-1
M=[]
for c in range(0,x):
if c==0:
M.append(L[x])
M.append(L[c])
print M
x=eval(raw_input("List:"))
Q17(x)
def Q3(L):
x=len(L)
M=[]
for c in range(0,x):
if c%2==0:
M.append(L[c+1])
else:
M.append(L[c-1])
print M
x=eval(raw_input("List:"))
Q3(x)
def Q(l):
M=len(l)/2
x=0
while M!=len(l):
l[x],l[M]=l[M],l[x]
x+=1
M+=1
print l
x=eval(raw_input("List:"))
Q(x)
def Q(l):
for c in range(0,len(l)):
for k in range(0,len(l)-c):
print l[k],
print "0 "*c
x=eval(raw_input("L:"))
Q(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment