Skip to content

Commit 40c51b9

Browse files
committed
Unit Converter lab Version 1 and 2
2 parents 7a45cca + 22496e7 commit 40c51b9

29 files changed

+1158
-18
lines changed

0 General/11 Git Lab Workflow.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,17 @@
2222

2323
1. Do some code changes.
2424

25-
1. Add all the changes made to git tracking (or add only `<filename>` or `<directoryname>` changes):
26-
`git add -A`
25+
1. Use `git status` to view what files and directories have been changed:
26+
`git status`
27+
28+
1. Use whichever or these four options is appropriate to add the necessary files to git tracking:
29+
`git add .`
30+
`git add <filepath>`
31+
`git add <directorypath>`
32+
`git add -A`
33+
34+
1. Use `git status` to view what files and directories will be added to the commit:
35+
`git status`
2736

2837
1. Commit the changes made to the branch:
2938
`git commit -m <commit message>`
@@ -33,8 +42,17 @@
3342

3443
1. Do some more code changes.
3544

36-
1. Add all the changes made to git tracking:
37-
`git add -A`
45+
1. Use `git status` to view what files and directories have been changed:
46+
`git status`
47+
48+
1. Use whichever or these four options is appropriate to add the necessary files to git tracking:
49+
`git add .`
50+
`git add <filepath>`
51+
`git add <directorypath>`
52+
`git add -A`
53+
54+
1. Use `git status` to view what files and directories will be added to the commit:
55+
`git status`
3856

3957
1. Commit the changes made to the branch:
4058
`git commit -m <commit message>`

1 Python/labs/03 Number To Phrases

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Lab 3: Number to Phrase
2+
Convert a given number into its english representation. For example: 67 becomes 'sixty-seven'. Handle numbers from 0-99.
3+
4+
Hint: you can use modulus to extract the ones and tens digit.
5+
6+
x = 67
7+
tens_digit = x//10
8+
ones_digit = x%10
9+
Hint 2: use the digit as an index for a list of strings OR as a key for a dict of digit:phrase pairs.
10+
11+
Version 2
12+
Handle numbers from 100-999.
13+
14+
Version 3 (optional)
15+
Convert a number to roman numerals.
16+
17+
Version 4 (optional)
18+
Convert a time given in hours and minutes to a phrase.

1 Python/labs/04 Black Jack Advice

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Lab 4: Blackjack Advice
2+
3+
Let's write a python program to give basic blackjack playing advice during a game by asking the player for cards.
4+
First, ask the user for three playing cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K).
5+
Then, figure out the point value of each card individually. Number cards are worth their number, all face cards are worth 10.
6+
At this point, assume aces are worth 1. Use the following rules to determine the advice:
7+
8+
Less than 17, advise to "Hit"
9+
Greater than or equal to 17, but less than 21, advise to "Stay"
10+
Exactly 21, advise "Blackjack!"
11+
Over 21, advise "Already Busted"
12+
13+
Print out the current total point value and the advice.
14+
15+
What's your first card? Q
16+
What's your second card? 2
17+
What's your third card? 3
18+
15 Hit
19+
20+
What's your first card? K
21+
What's your second card? 5
22+
What's your third card? 5
23+
20 Stay
24+
25+
What's your first card? Q
26+
What's your second card? J
27+
What's your third card? A
28+
21 Blackjack!
29+
30+
Version 2 (optional)
31+
32+
Aces can be worth 11 if they won't put the total point value of both cards over 21. Remember that you can have multiple aces in a hand.
33+
Try generating a list of all possible hand values by doubling the number of values in the output whenever you encounter an ace.
34+
For one half, add 1, for the other, add 11. This ensures if you have multiple aces that you account for the full range of possible values.

1 Python/labs/05 Pick6

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Lab 5: Pick6
2+
3+
Have the computer play pick6 many times and determine net balance.
4+
5+
Initially the program will pick 6 random numbers as the 'winner'. Then try playing pick6 100,000 times, with the ticket cost and payoff below.
6+
7+
A ticket contains 6 numbers, 1 to 99, and the number of matches between the ticket and the winning numbers determines the payoff.
8+
Order matters, if the winning numbers are [5, 10] and your ticket numbers are [10, 5] you have 0 matches.
9+
If the winning numbers are [5, 10, 2] and your ticket numbers are [10, 5, 2], you have 1 match. Calculate your net winnings (the sum of all expenses and earnings).
10+
11+
a ticket costs $2
12+
if 1 number matches, you win $4
13+
if 2 numbers match, you win $7
14+
if 3 numbers match, you win $100
15+
if 4 numbers match, you win $50,000
16+
if 5 numbers match, you win $1,000,000
17+
if 6 numbers match, you win $25,000,000
18+
19+
One function you might write is pick6() which will generate a list of 6 random numbers, which can then be used for both the winning numbers and tickets.
20+
Another function could be num_matches(winning, ticket) which returns the number of matches between the winning numbers and the ticket.
21+
Steps
22+
23+
Generate a list of 6 random numbers representing the winning tickets
24+
Start your balance at 0
25+
Loop 100,000 times, for each loop:
26+
Generate a list of 6 random numbers representing the ticket
27+
Subtract 2 from your balance (you bought a ticket)
28+
Find how many numbers match
29+
Add to your balance the winnings from your matches
30+
After the loop, print the final balance
31+
32+
Version 2
33+
34+
The ROI (return on investment) is defined as (earnings - expenses)/expenses. Calculate your ROI, print it out along with your earnings and expenses.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Presentation Day: November 4th, 2022
3030
| Lab | Name | Date Assigned | Due By Start Of Class | Hard Due Date |
3131
| --- | ---------------------- | ------------- | --------------------- | ------------- |
3232
| 01 | Lab Average Numbers | 28 Jun | 05 Jul | 12 Jul |
33-
| 02 | Lab | 00 Jun | 00 Jun | 00 Jun |
34-
| 03 | Lab | 00 Jun | 00 Jun | 00 Jun |
35-
| 04 | Lab | 00 Jun | 00 Jun | 00 Jun |
36-
| 05 | Lab | 00 Jun | 00 Jun | 00 Jun |
33+
| 02 | Lab Unit Converter | 30 Jun | 08 Jul | 14 Jul |
34+
| 03 | Lab Number To Phrase | 01 Jul | 09 Jul | 15 Jul |
35+
| 04 | Lab Black Jack Advice | 06 Jul | 13 Jul | 20 Jul |
36+
| 05 | Lab Pick6 | 07 Jul | 14 Jul | 21 Jul |
3737
| 06 | Lab | 00 Jun | 00 Jun | 00 Jun |
3838
| 07 | Lab | 00 Jun | 00 Jun | 00 Jun |
3939
| 08 | Lab | 00 Jun | 00 Jun | 00 Jun |

code/Andy/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Andy
44

55
Github Username:
66
andy2124
7+

code/Andy/python.py

Whitespace-only changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#version 1
2+
units = {
3+
"feet": 0.3048,
4+
"meters": 1
5+
}
6+
distance = input("Enter Lenth of feet:")
7+
distance= int(distance)
8+
total = distance * units["feet"]
9+
print(f"{distance} FT is {total} Meters")
10+
11+
#version 2
12+
units_mesurments = {
13+
"feet": 0.3048,
14+
"miles": 1609.34,
15+
"meters": 1,
16+
"kilometers": 1000
17+
}
18+
19+
distance = input("what is the distance?")
20+
units = input("what are the units?:")
21+
calling = units_mesurments[units]
22+
distance = int(distance)
23+
total = distance * calling
24+
25+
print(f"{distance} {units} is {total} Meters")
26+
27+
#version 3
28+
units_mesurments = {
29+
"feet": 0.3048,
30+
"miles": 1609.34,
31+
"meters": 1,
32+
"kilometers": 1000,
33+
"yards": 0.9144,
34+
"inches": 0.0254
35+
}
36+
37+
distance = input("what is the distance?")
38+
units = input("what are the units?:")
39+
calling = units_mesurments[units]
40+
distance = int(distance)
41+
total = distance * calling
42+
43+
print(f"{distance} {units} is {total} Meters")

code/IWilliams/Python/Exceptions

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
try:
2+
num = int(input('Enter a number: '))
3+
divide_num = 100/num
4+
except (ValueError, ZeroDivisionError):
5+
print('Please enter a number other than zero')
6+
# print(ex, 'printing the ex error')
7+
# print(type(ex))
8+
# except ZeroDivisionError:
9+
# print('Number cannot = zero')
10+
11+
else:
12+
print('We are printing the else clause')
13+
14+
15+
message = input('Enter a number ')
16+
try:
17+
number = float(message)
18+
except ValueError:
19+
print('Please enter a number')
20+
else:
21+
print('Your number converted successfully')
22+
finally:
23+
print('Finally is printing')
24+
25+
26+
names = ['Peter', 'Parker', 'Storm']
27+
while True:
28+
message = input('Enter a number ')
29+
30+
try:
31+
number = int(message)
32+
names[number] #names[0]
33+
break
34+
except(ValueError, IndexError) as error:
35+
if type(error) == IndexError:
36+
print('We have an index error')
37+
else:
38+
print('Please a valid number')
39+
40+
# print(error, 'Printing except error')
41+
print('No error has occurred')

code/IWilliams/Python/Functions.py

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# def greet():
2+
# print('Good evening')
3+
# print('Welcome to Functions')
4+
5+
# greet()
6+
7+
8+
# def greet(first_name, last_name):
9+
# print(f'Hello {first_name}, {last_name}')
10+
11+
# greet('Wayne', 'Bruce')
12+
# greet('Grey', 'Jean')
13+
# greet('Jean', 'Grey')
14+
15+
16+
# 2 function types --> Values and Task
17+
#Task
18+
# def greet(name):
19+
# print(f'{name}, from print function')
20+
# return name #value from function
21+
22+
# print(greet('Joe'))
23+
24+
25+
#Value
26+
# def get_greeting(name):
27+
# return f'Good evening {name}'
28+
# message = get_greeting('Paul')
29+
# file = open('get_greeting.txt', 'w')
30+
# file.write(message)
31+
# file.close()
32+
33+
34+
# #flush this out..
35+
# def get_greeting2():
36+
# results = get_greeting()
37+
# return results
38+
39+
# print(get_greeting2('Larry'))
40+
41+
42+
# def increment(number, by):
43+
# return number + by
44+
45+
# result = increment(3, 1)
46+
# print(result)
47+
48+
49+
# def increment(number, by=1):
50+
# return number + by
51+
# print(increment(2))
52+
53+
54+
# def increment(number, by=1):
55+
# return number + by
56+
# print(increment(2, 13))
57+
58+
# def increment(num1=1, num2=1):
59+
# return num2 +num1
60+
# print(increment(num2=5, num1=13))
61+
62+
63+
#this will result in Typeerror
64+
# def multiply(a, b):
65+
# return a*b
66+
67+
# print(multiply(2, 4, 6, 8))
68+
69+
#xargs
70+
# def multiply(*nums): #[2, 4, 6, 8]
71+
# total = 1
72+
# for n in nums:
73+
# #print(n)
74+
# #total = total * n
75+
# total *=n
76+
# return total
77+
78+
# print(multiply(2, 4, 6, 8))
79+
80+
#xxargs --> key/word
81+
# def user_demographics(**user):
82+
# print(user['name'], user['confirmed'])
83+
84+
# user_demographics(id=100, name='Parker', age=35, confirmed ='N')
85+
86+
# def patient():
87+
# MRN = '7VLYZ'
88+
89+
#print(MRN) #not accessible to local scope
90+
91+
# MRN = 'Z10111'
92+
# def patient(name):
93+
# MRN = '85RZLL'
94+
95+
# def doctor(name):
96+
# MRN = '67382C'
97+
98+
# patient('Smith')
99+
# print(MRN)
100+
101+
# def repeat(quote, num):
102+
# print(quote * num)
103+
104+
# print(repeat('Live your best life ', 5)'
105+
106+
# def get_temp(temp):
107+
# if temp > 90:
108+
# return 'Hot'
109+
# elif temp >75 and temp <=90:
110+
# return 'Warm'
111+
# elif 60 <temp <=75:
112+
# return 'Comfortable'
113+
# elif 45 <temp <=60:
114+
# return 'Chilly'
115+
# else:
116+
# return 'Pack your parka'
117+
118+
119+
# print(get_temp(40))
120+
121+

0 commit comments

Comments
 (0)