Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Arijit2003 authored Nov 1, 2021
1 parent d9f2a31 commit fc6ce02
Show file tree
Hide file tree
Showing 27 changed files with 1,021 additions and 0 deletions.
132 changes: 132 additions & 0 deletions Lab exercise 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#1)
A=int(input("Enter RS:"))
D=A/74.73
print(A,"in $ is",D)
def dollar_from_RS(B):
D=B/74.73
return D
F=int(input("Enter RS:"))
print(dollar_from_RS(F))

def Rs_to_dollar(a):
dollar=a/74.73
print(dollar)
r=int(input("Enter Rs:"))
Rs_to_dollar(r)
#2)
A=input("Enter Character:")
print("The ASCSII value",ord(A))

#3)
X=0
Y=1
while X<=100:
print(X)
(X,Y)=(Y,X+Y)


#4)Factorial
def factorial(A):
mul=1
for X in range(1,A+1):
mul=mul*X
print("factorial of",A,"is",mul)
factorial(int(input("Enter any number:")))
#Program on Control Flow (Conditional & Loops)
#1)
A=int(input("Enter Number:"))
i=0
Sum=0
for X in str(A):
W=int(X)*10**i
Sum=Sum+W
i=i+1
print(Sum)
#2)

A=int(input("Enter Number:"))
if A>0:
print("The number is positive.")
elif A<0:
print("The number is negative.")
else:
print("The number is",0)


#Program on Functions


#1)
def maximum(a,b,c):
if a>b and a>c:
print(a,"is the maximum")
elif b>a and b>c :
print(b,"is the maximum")
else:
print(c,"is the maximum")

maximum(10,15,24)

#2)
A=[1,2,3,4,5,6,78,9,8]
mul=1
for X in A:
mul=mul*X
print(mul)

#3)
def unique_list(a):
S=set((a))
L=list((S))
L.sort()
print(L)
unique_list([1,2,3,4,1,2,5,9,8,7,8])

#4)
def multiplication():
a=int(input("Enter 1st number:"))
b=int(input("Enter 2nd number:"))
def multiplication2(c,d):
D=c*d
print(D)
multiplication2(a,b)
multiplication()

#5)
def square(num):
D=num**2
return D
def cube(num2):
J=num2**3
return J
A=[1,2,3,4,5,6,7,8,9]
B=(1,20,3,40,54,6,79.9,8,9)
C={1,2.5,3,4,0.5,67.336,7,81,92}
print(list(map(square,A)))
print(set(map(cube,B)))
print(tuple(map(square,C)))
squ=lambda X:X**2
cube1=lambda Y:Y**3
print(list(map(cube1,A)))
print(tuple(map(squ,B)))





















5 changes: 5 additions & 0 deletions circulating_in_a_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def circulate(list,n):
print(list)
list=list[n:]+list[:n]
print(list)
circulate([1,2,3,4,5,6,7,8,9],-2)
91 changes: 91 additions & 0 deletions classactivity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#1) Write a Python program to count the number of even and odd numbers from a series of numbers.

#Sample numbers : numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9)

numbers=(1,2,3,4,5,6,7,8,9)
count=0
countf=0
for X in numbers:
if X%2==0:
count+=1
if X%2!=0:
countf+=1
print("number of even numbers are",count)
print("number of odd numbers are",countf)

#2) Write a Python program that prints all the numbers from 0 to 6 except 3 and 6.
for Y in range(0,7):
if Y==3 or Y==6:
continue
else:
print(Y)
#4)Create a list and find the largest element in a list using max() function by passing objects as arguments (numbers).
A=[1,2,3,4,5,6,7,8,9]
print(max(A))

#5). Print the sum of the given list.

# my_list = [10,20,30,40,50,50,60,10]
my_list=[10,20,30,40,50,50,60,10]
print(sum(my_list))

#6)Python function to add two variables values with the following:
#i) with return
def addition(U,V):
S=U+V
return S
print(addition(5,9))
#ii)without return
def addition2(D,F):
P=D+F
print(P)
addition2(10.464055,15.3259)

#7)Find out the student’s grade from the marks obtained by the student.
a=int(input("Enter Your Obtained marks:"))
if a>=95:
print("Your Grade is A+")
elif a>=90:
print("Your Grade is A")
elif a>=85:
print("Your Grade is B+")
elif a>=70:
print("Your Grade is B")
elif a>=50:
print("Your Grade is C")
elif a>=45:
print("Your Grade is D")
else:
print("Fail")
#8)Compare two lists in Python and display the corresponding results.
W=[1,2,3,34,5,69,8,14]
Q=[2,1,34,14,8,3,5,69]
W.sort()
Q.sort()
if W==Q:
print("Compared lists are equal")
else:
print("Compared lists are not equal")























Loading

0 comments on commit fc6ce02

Please sign in to comment.