Skip to content

Commit 12d0509

Browse files
authored
pset2 code
1 parent b25de66 commit 12d0509

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

week2/camel/camel.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
text = input("camelCase: ")
2+
output = ""
3+
4+
for char in text:
5+
if char.isupper():
6+
output += '_' + char.lower()
7+
else:
8+
output += char
9+
print("snake_case:", output)

week2/coke/coke.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
due = 50
2+
3+
while True:
4+
print("Amount Due:", due)
5+
money = int(input("Insert Coin: "))
6+
if money == 25 or money == 10 or money == 5:
7+
if(money >= due):
8+
print("Change Owed:", money-due)
9+
break
10+
due -= money
11+
else:
12+
continue

week2/plates/plates.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def main():
2+
plate = input("Plate: ")
3+
if is_valid(plate):
4+
print("Valid")
5+
else:
6+
print("Invalid")
7+
8+
9+
def is_valid(s):
10+
if s[0:2].isalpha() and len(s)<7 and s[-1].isnumeric():
11+
return True
12+
13+
main()

week2/twttr/twttr.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def main():
2+
text = input("Input: ")
3+
output = ""
4+
5+
for i in text:
6+
if isnotvowel(i):
7+
output += i
8+
9+
print(f"Output: {output}")
10+
11+
def isnotvowel(n):
12+
if n not in 'aeiouAEIOU':
13+
return True
14+
15+
main()

0 commit comments

Comments
 (0)