Skip to content

Commit c956dff

Browse files
committed
Merge branch 'master' of https://github.com/hemangsk/python-on
2 parents df5a521 + 31b867a commit c956dff

File tree

7 files changed

+51
-0
lines changed

7 files changed

+51
-0
lines changed

Basic/24HourClock.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
currentTime = input("What's the current time (24 Hours clock) ? ")
2+
delayTime = input("Alarm must ring after how many hours ? ")
3+
waitTime = (int(currentTime) + (int(delayTime) % 24))%24
4+
print("Alarm time will be", waitTime, "hours.")

Basic/daysOfWeek.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
It is possible to name the days 0 through 6 where day 0 is Sunday and day 6 is Saturday. If you go on a wonderful holiday leaving on day number 3 (a Wednesday) and you return home after 10 nights. Write a general version of the program which asks for the starting day number, and the length of your stay, and it will tell you the number of day of the week you will return on.
3+
4+
"""
5+
6+
starting = input("Starting Day ?")
7+
lengthOfStay = input("Length of stay ?")
8+
9+
returnDay = (int(starting) % 7 + int(lengthOfStay)%7 ) % 7
10+
11+
print("Day of return", returnDay)

Basic/degreeAndFahreinheit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
degree =float(input("Enter degree = ?"))
2+
print("Fahreinheit", degree*(9/5) + 32)

Basic/simpleInterest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Compute final amount using formula of compound interest
3+
"""
4+
5+
principal =int( input("Principal Amount ? "))
6+
rate =int (input("Annual nominal interest rate ? "))
7+
compoundCount = int( input("Number of times the interest is compounded per year ? "))
8+
time = int(input("Number of years ?"))
9+
10+
print ("Amount = Rs", principal * ( (1 + rate/compoundCount)** (compoundCount * time)))

Module Basic/10randomNumbers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import random
2+
3+
for i in range(0,9):
4+
print(random.random())

Module Basic/printRangeRand.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
print 10 random numbers between 25 and 35.
3+
"""
4+
5+
import random
6+
7+
for i in range(0,10):
8+
print(random.randrange(26,35))
9+

Recursion/decToBinary.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def decToBinary(n):
2+
if(n==1):
3+
return "1"
4+
elif(n==0):
5+
return "0"
6+
else:
7+
return decToBinary(int(n/2)) + str(n%2)
8+
9+
10+
num = int(input("Enter decimal number to convert to binary - "))
11+
print("Binary equivalent of", num, "is equal to " + decToBinary(num))

0 commit comments

Comments
 (0)