Skip to content

Commit f2dc4f5

Browse files
Initial commit
1 parent f1a7ad3 commit f2dc4f5

32 files changed

+319
-0
lines changed

logic-1/alarm_clock.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def alarm_clock(day, vacation):
2+
if(vacation == "yes"):
3+
if(1 <= day <= 5):
4+
return "10:00"
5+
else:
6+
return "off"
7+
8+
else:
9+
if(1 <= day <= 5):
10+
return "7:00"
11+
else:
12+
return "10:00"
13+
14+
day = raw_input("Day of the week - (0 - 7, sunday being 0) ")
15+
vacation = raw_input("On vacation? (yes or no) ")
16+
17+
print(alarm_clock(day,vacation))

logic-1/caught_speeding.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def caught_speeding(speed, is_birthday):
2+
speed0 = 60
3+
speed1 = 61
4+
speed2 = 81
5+
6+
if(is_birthday == "yes"):
7+
speed0 = speed0 + 5
8+
speed1 = speed1 + 5
9+
speed2 = speed2 + 5
10+
11+
if(speed <= speed0):
12+
return 0
13+
elif(speed1 <= speed < speed2):
14+
return 1
15+
elif(speed2 <= speed):
16+
return 2
17+
18+
speed = input("What is your speed? ")
19+
is_birthday = raw_input("Is it your birthday? (yes or no) ")
20+
21+
print(caught_speeding(speed,is_birthday))

logic-1/cigar_party.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def cigar_party(cigars, is_weekend):
2+
if(is_weekend == "yes"):
3+
return (cigars >= 40)
4+
else:
5+
return (40 <= cigars <=60)
6+
7+
cigars = input("How many cigars?: ")
8+
is_weekend = raw_input("Is it a weekend? (yes or no) ")
9+
10+
print(cigar_party(cigars,is_weekend))

logic-1/date_fashion.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def date_fashion(you, date):
2+
if(you <= 2 or date <=2):
3+
return 0
4+
elif(you >= 8 or date >= 8):
5+
return 2
6+
else:
7+
return 1
8+
9+
you = input("Your rate (0 - 10): ")
10+
date = input("Your date's rate (0 - 10): ")
11+
12+
print(date_fashion(you,date))

logic-1/in1to10.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def in1to10(n, outside_mode):
2+
if(outside_mode == "yes"):
3+
if(n <= 1 or n >= 10):
4+
return True
5+
else:
6+
return False
7+
8+
elif(1 <= n <= 10):
9+
return True
10+
else:
11+
return False
12+
13+
n = input("Enter a number: ")
14+
outside_mode = raw_input("Outside mode? (yes or no) ")
15+
16+
print(in1to10(n,outside_mode))

logic-1/love6.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def love6(a, b):
2+
if(a == 6 or b == 6 or (a + b == 6) or (a - b == 6) or (b - a == 6)):
3+
return True
4+
else:
5+
return False
6+
7+
a = input("Enter a number: ")
8+
b = input("Enter a second number: ")
9+
10+
print(love6(a,b))

logic-1/near_ten.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def near_ten(num):
2+
return num % 10 in [0,1,2,8,9,10]
3+
4+
num = input("Enter a number: ")
5+
6+
print(near_ten(num))

logic-1/sorta_sum.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def sorta_sum(a, b):
2+
sum = a + b
3+
if(10 <= sum <= 19):
4+
return 20
5+
else:
6+
return sum
7+
8+
a = input("Enter a number: ")
9+
b = input("Enter a second number: ")
10+
11+
print(sorta_sum(a,b))

logic-1/squirrel_play.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def squirrel_play(temp, is_summer):
2+
if(is_summer == "yes"):
3+
return (60 <= temp <= 100)
4+
else:
5+
return (60 <= temp <= 90)
6+
7+
temp = input("What is the temperature?: ")
8+
is_summer = raw_input("Is it summer? (yes or no) ")
9+
10+
print(squirrel_play(temp,is_summer))

string-1/combo_string.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def combo_string(a, b):
2+
a_length = len(a)
3+
b_length = len(b)
4+
if(a_length > b_length):
5+
return b + a + b
6+
else:
7+
return a + b + a
8+
9+
a = raw_input("Enter a string: ")
10+
b = raw_input("Enter a second string: ")
11+
12+
print(combo_string(a,b))

0 commit comments

Comments
 (0)