Skip to content

Commit 4d7e18a

Browse files
author
Pc
committed
updated solution
1 parent f77e0da commit 4d7e18a

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

Solutions/Excercise4.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def main():
2+
x=11
3+
y=2
4+
print("Addition X+Y=",x+y)
5+
print("Subtraction X-Y=",x-y)
6+
print("Multiplication X*Y=",x*y)
7+
print("Division X/Y=",x/y)
8+
print("Modulus X%Y=",x%y)
9+
print("Exponent X**Y=",x**y)
10+
print("Floor Division X//Y=",x//y)
11+
12+
if __name__ == '__main__':
13+
main()

Solutions/Excercise5.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def main():
2+
x=78
3+
if(x>=90):
4+
print("Eligible For Research")
5+
elif (x>70) and (x<90):
6+
if(x>75):
7+
print("Eligible for Placement")
8+
print("Distinction")
9+
else:
10+
print("Fail")
11+
12+
if __name__ == '__main__':
13+
main()

Solutions/Excercise6.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def main():
2+
x=4
3+
y=2
4+
print("Bitwise AND X&Y=", x&y )
5+
print("Bitwise OR X|Y=", x|y )
6+
print("Bitwise XOR X^Y=", x^y )
7+
print("Bitwise Complement ~X=", ~x )
8+
print("Bitwise Left Shift X<<Y=", x<<y )
9+
print("Bitwise Right Shift X>>Y=", x>>y )
10+
11+
if __name__ == '__main__':
12+
main()

Solutions/Excercise7.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'''
2+
Enter a String : Introduction To Python
3+
Required Output = ['y', 't', 't', 'o', 'o', 'n', 'n', 'h', 'c', 'P', ' ']
4+
'''
5+
def main():
6+
inputString= input("Enter a String : ")
7+
inputList=list(inputString)
8+
inputList.sort()
9+
inputList.reverse()
10+
print("Required Output = ",inputList[::2])
11+
12+
if __name__ == '__main__':
13+
main()

Solutions/Excercise8.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'''
2+
Enter a number : 5
3+
Required Output = factorial of 5 is : 120
4+
'''
5+
def factorial(number):
6+
if (number<=1):
7+
return 1
8+
else:
9+
return (number*factorial(number-1))
10+
11+
def main():
12+
inputNum = int(input("Enter a Number : "))
13+
print("factorial of "+str(inputNum)+" is :",factorial(inputNum))
14+
15+
if __name__ == '__main__':
16+
main()

0 commit comments

Comments
 (0)