Skip to content

Commit 7b3ae14

Browse files
Added BitwiseOperators, LostCardProbelm, SineTaylorSeries
1 parent 67f0430 commit 7b3ae14

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

BitwiseOperators.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
a=5
2+
c=int(input("Enter a num"))
3+
print(a&c, a|c) #bitwise and, bitwise or
4+
b=a>>c #Right shift
5+
d=a<<c #Left Shift
6+
print(b)
7+
print(d)
8+
print(a)
9+
x=-3
10+
print(~x) #Bitwise Complement
11+
y=int(input("Enter a num: "))
12+
print(y^y^y)

LostCardProblem.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
for _ in range(int(input("Enter the number of testcases: "))):
2+
print("\n\n\nWelcome, We will find one of your lost card...")
3+
print("\n1. Series Cards\n2. Random Cards\n3. Exit\n\n")
4+
ch=4
5+
a=0
6+
sum=0
7+
while(ch!=1 and ch!=2 and ch!=3):
8+
print("Please, Press 1, 2 or 3... ")
9+
ch=input()
10+
try:
11+
ch=int(ch)
12+
except:
13+
pass
14+
if(ch==3):
15+
exit()
16+
else:
17+
n=int(input("Enter the total number of cards you had: "))
18+
if(ch==1):
19+
a=n*(n+1)//2
20+
else:
21+
print("Enter all the",n,"cards you had: ")
22+
for i in range(1,n+1):
23+
a=a+int(input())
24+
print("Now, enter",n-1,"cards you have now: ")
25+
for i in range(n-1):
26+
sum=sum+int(input())
27+
print("Lost Card: ",a-sum)

SineTaylorSeries.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def fact(x):
2+
if x==0 or x==1:
3+
return 1
4+
else:
5+
return x*fact(x-1)
6+
def sin(x,n):
7+
power=1
8+
sign=1
9+
s=0
10+
for i in range(n):
11+
s=s+(sign*(x**power)/fact(power))
12+
power=power+2
13+
sign=sign*-1
14+
return s
15+
print("This program will calculate value of sinx using taylor series upto n terms: ")
16+
x=float(input("Enter the value of x: "))
17+
n=int(input("Enter the value of n: "))
18+
print("Calculating...")
19+
print("Value of sinx upto n-terms using taylor series is: ",sin(x,n))

0 commit comments

Comments
 (0)