Skip to content

Commit 9af10ad

Browse files
committed
Added capstone and milestone project
1 parent 44c57d4 commit 9af10ad

14 files changed

+891
-3
lines changed

.vscode/settings.json

-3
This file was deleted.

Final Capstone Project/Alarm_clock.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import datetime
2+
3+
t = input("Enter the time in minuts to set Alarm : ")
4+
t = datetime.time(0, int(t))
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from functools import reduce
2+
3+
4+
def binary(num):
5+
num = int(num)
6+
rem = []
7+
while num:
8+
rem.append(num % 2)
9+
num //= 2
10+
11+
rem = rem[::-1]
12+
return reduce(lambda x, y: x*10+y, rem)
13+
14+
15+
def decimal(num):
16+
num = list(num)
17+
lst = []
18+
for i in range(len(num)):
19+
lst.append(int(num[i])*(2**i))
20+
return sum((lst))
21+
22+
23+
print("\tBinary Convertor")
24+
print("1.Decimal to Binary\n2. Binary to Decimal")
25+
ch = int(input("Enter your choice : "))
26+
num = input("Enter the number : ")
27+
if ch == 1:
28+
result = binary(num)
29+
elif ch == 2:
30+
result = decimal(num)
31+
else:
32+
print("Wrong choice...!!")
33+
exit()
34+
35+
print(result)
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from math import *
2+
3+
4+
def distance(coord1, coord2):
5+
"""
6+
This uses the formula 'haversine' to calculate the great-circle distance b/w two points - that is the shortest distance over the earth surface.
7+
8+
"""
9+
10+
lat1, long1 = coord1
11+
lat2, long2 = coord2
12+
R = 6371
13+
a = (sin((lat2 - lat1)/2))**2 + cos(lat1) * \
14+
cos(lat2)*(sin((long2 - long1)/2))**2
15+
c = 2 * (atan2(a**0.5, (1-a)**0.5))
16+
d = R * c
17+
return d
18+
19+
20+
if __name__ == "__main__":
21+
print("\n\nEnter The co-ordinate of two cities : \n")
22+
latitude1, longitude1 = (float(x) for x in input(
23+
"Enter Latitude and Longitude : ").split())
24+
latitude2, longitude2 = (float(x) for x in input(
25+
"Enter Latitude and Longitude : ").split())
26+
27+
dist = distance((latitude1, longitude1), (latitude2, longitude2))
28+
29+
print("Choose your unit to display : ")
30+
print("The Distance between two cities : \n")
31+
print("1. Kilometers\n2. Meters\n3. Miles\n4. Inches\n5. Foot\n6. Yard\n7. Light Year\n0. Exit")
32+
ch = int(input("Enter your choice : "))
33+
if ch == 0:
34+
print("Thank You..!!")
35+
exit()
36+
elif ch == 1:
37+
pass
38+
elif ch == 2:
39+
pass
40+
elif ch == 3:
41+
pass
42+
elif ch == 4:
43+
pass
44+
elif ch == 5:
45+
pass
46+
elif ch == 6:
47+
pass
48+
elif ch == 7:
49+
pass
50+
else:
51+
print("Wrong Choice..!!")
52+
print("Try Again....")
53+
print(dist)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def fibnacci(num):
2+
a, b = 0, 1
3+
while num:
4+
yield a
5+
a, b = b, a+b
6+
num -= 1
7+
8+
9+
def fib_seq(num):
10+
a, b = 0, 1
11+
while True:
12+
yield a
13+
a, b = b, a+b
14+
if num < a:
15+
break
16+
17+
18+
n = int(input("Enter any number : "))
19+
print(f"Fibnacci sequence upto {n} terms = ")
20+
for t in fibnacci(n):
21+
print(t)
22+
23+
print(f"\nFibnacci sequence upto {n} = ")
24+
25+
for t in fib_seq(n):
26+
print(t)
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def find_cost(cost_per_tile, w, h):
2+
'''
3+
Return the total cost of tile to cover
4+
WxH floor
5+
'''
6+
return cost_per_tile * (w*h)
7+
8+
9+
w, h = (int(x) for x in input("Enter W and H : ").split())
10+
cost_tile = float(input("Enter the cost per tile : "))
11+
print("Total cost of tile to cover WxH floor : = {:.3f}".format(
12+
find_cost(cost_tile, w, h)))

Final Capstone Project/FindPI.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from math import pi
2+
n = int(input("Enter a number : "))
3+
if n > 15 or n < 0:
4+
print("Please Enter the value between 0 to 15 .!!")
5+
else:
6+
p = str(pi)
7+
print("PI upto {} decimal place = {}".format(n, p[:n+2]))

Final Capstone Project/Find_e.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from math import e
2+
3+
n = int(input("Enter a number : "))
4+
if n > 15 or n < 0:
5+
print("Please Enter the value between 0 to 15 .!!")
6+
else:
7+
e_val = str(e)
8+
print("e upto {} decimal place = {}".format(n, e_val[:n+2]))

Final Capstone Project/Find_prime.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def find_prime(num):
2+
lst = []
3+
for i in range(2, num):
4+
if num % i == 0:
5+
lst.append(i)
6+
return lst
7+
8+
9+
n = int(input("Enter any number : "))
10+
primes = find_prime(n)
11+
12+
if primes == []:
13+
print(f"{n} is a prime number. The prime numbers don't have prime factors.\nThank you!!")
14+
else:
15+
print(f"Prime factors of {n} are = \n{primes} ")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
loan = float(input("Enter the amount of loan : "))
2+
roi = float(input("Enter rate of intrest : "))
3+
print("How you want to pay the loan : ")
4+
print("1. Monthly\n2. Weekly\n3. Daily\n4. Continually")
5+
ch = int(input("Enter your choice : "))
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
def is_prime(num):
2+
3+
if num == 2:
4+
return True
5+
6+
if num % 2 == 0:
7+
return False
8+
9+
for i in range(3, int(num**0.5)+1, 2):
10+
if num % i == 0:
11+
return False
12+
13+
return True
14+
15+
16+
def prime_gen(current_prime):
17+
18+
next_prime = current_prime + 1
19+
20+
while True:
21+
22+
if not is_prime(next_prime):
23+
next_prime += 1
24+
25+
else:
26+
break
27+
return next_prime
28+
29+
30+
current_prime = 2
31+
while True:
32+
33+
answer = input('Would you like to see the next prime? (Y/N) ')
34+
35+
if answer[0].lower() == 'y':
36+
print(current_prime)
37+
current_prime = prime_gen(current_prime)
38+
39+
else:
40+
break
41+
42+
print("Thanks..!!")

0 commit comments

Comments
 (0)