Skip to content

Commit 7d3121e

Browse files
committed
Merge branch 'main' of https://github.com/PdxCodeGuild/class_HB2 into kelin-lab03-number-to-phrases
2 parents 575f58e + 7d7fc3e commit 7d3121e

File tree

9 files changed

+414
-67
lines changed

9 files changed

+414
-67
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/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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ Presentation Day: November 4th, 2022
3232
| 01 | Lab Average Numbers | 28 Jun | 05 Jul | 12 Jul |
3333
| 02 | Lab Unit Converter | 30 Jun | 08 Jul | 14 Jul |
3434
| 03 | Lab Number To Phrase | 01 Jul | 09 Jul | 15 Jul |
35-
| 04 | Lab | 00 Jun | 00 Jun | 00 Jun |
36-
| 05 | Lab | 00 Jun | 00 Jun | 00 Jun |
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 |
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# ab 00: Average Numbers
2+
3+
# We're going to average a list of numbers. Start with the following list, iterate through it, keeping a 'running sum', then divide that sum by the number of elements in that list. Remember len will give you the length of a list.
4+
5+
# The code below shows how to loop through an array, and prints the elements one at a time.
6+
7+
# nums = [5, 0, 8, 3, 4, 1, 6]
8+
# runningSum = 0
9+
10+
# # loop over the elements
11+
# for num in nums:
12+
# runningSum += num
13+
# # print(runningSum)
14+
15+
# avgNum = runningSum / len(nums)
16+
# print(avgNum)
17+
18+
19+
20+
21+
# # Version 2
22+
23+
# # Ask the user to enter the numbers one at a time, putting them into a list. If the user enters 'done', then calculate and display the average. The following code demonstrates how to add an element to the end of a list.
24+
# from cProfile import run
25+
26+
27+
runningSum = 0
28+
inputCount = 0
29+
numList = []
30+
31+
32+
lab1 = True
33+
while lab1 == True:
34+
enterNum = input("Enter a number or type 'done' when finished: ")
35+
if enterNum != "done":
36+
try:
37+
enterNum = float(enterNum)
38+
numList.append(float(enterNum))
39+
except:
40+
print("Type a number")
41+
else:
42+
lab1 = False
43+
for num in numList:
44+
runningSum += num
45+
avgNum = runningSum / len(numList)
46+
47+
print(f"runningSum = {runningSum}, avgNum = {avgNum}")
48+
print(numList)
49+
50+

code/kaceyb/python/lab02/lab_02.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66

77

8+
9+
810
conversion_list = {
911
'foot': 0.3048,
1012
'mile': 1609.34,
@@ -129,4 +131,4 @@
129131
print(f"{users_distance_input} {users_unit_input} is {result}")
130132

131133
user = False
132-
134+

code/kaceyb/python/lab03/lab_03.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# def get_greeting(name):
2+
# return f'Good evening {name}'
3+
# message = get_greeting('Vick')
4+
# file = open('get_greeting.txt', 'a')
5+
# file.write(message)
6+
# file.close()
7+
8+
9+
# def increment(num1=1, num2=1):
10+
# return num1 + num2
11+
# print(increment(5, 13))
12+
13+
14+
#results in Typeerror
15+
# def multiply(*nums):
16+
# total = 1
17+
# for n in nums:
18+
# total *= n
19+
# return total
20+
21+
22+
# print(multiply(2, 4, 6, 8))
23+
24+
# def repeat(quote, num):
25+
# print(quote * num)
26+
27+
# print(repeat(f'\nLive your best life', 5))
28+
29+
# def get_temp(temp):
30+
# if temp > 90:
31+
# return 'Hot'
32+
# elif temp > 75 and temp <= 90:
33+
# return 'Warm'
34+
# elif 60 <temp <= 75:
35+
# return 'Comfortable'
36+
# elif 45 <temp <= 60:
37+
# return 'Chilly'
38+
# else:
39+
# return 'Pack your parka'
40+
41+
# print(get_temp(40))
42+
43+
44+
from cmath import e
45+
46+
47+
number_words = {
48+
0: "zero",
49+
1: "one",
50+
2: "two",
51+
3: "three",
52+
4: "four",
53+
5: "five",
54+
6: "six",
55+
7: "seven",
56+
8: "eight",
57+
9: "nine",
58+
10: "ten",
59+
11: "eleven",
60+
12: "twelve",
61+
13: "thirteen",
62+
14: "fourteen",
63+
15: "fifteen",
64+
16: "sixteen",
65+
17: "seventeen",
66+
18: "eighteen",
67+
19: "nineteen",
68+
20: "twenty",
69+
30: "thirty",
70+
40: "forty",
71+
50: "fifty",
72+
60: "sixty",
73+
70: "seventy",
74+
80: "eighty",
75+
90: "ninety",
76+
100: "hundred"
77+
78+
}
79+
80+
try:
81+
number = int(input("Give a numerical number to convert to written English: "))
82+
except:
83+
print("Must enter a number.")
84+
quit()
85+
86+
87+
88+
89+
tens_digit = number//10
90+
ones_digit = number%10
91+
ten_column = int(str(tens_digit) + "0")
92+
93+
# VERSION 2 #
94+
hundreds_digit = number//100
95+
hundreds_column = int(str(hundreds_digit) + "00")
96+
tens_column2 = int(str(tens_digit%10) + "0")
97+
tens_digit2 = tens_column2 + ones_digit
98+
99+
if number == 0:
100+
print("zero")
101+
102+
elif hundreds_digit > 0:
103+
if ones_digit == 0 and tens_column2 == 0:
104+
print(number_words[hundreds_digit] + "-hundred")
105+
elif ones_digit == 0:
106+
print(number_words[hundreds_digit] + "-hundred-" + number_words[tens_column2])
107+
elif tens_column2 < 10:
108+
print(number_words[hundreds_digit] + "-hundred-" + number_words[ones_digit])
109+
elif tens_column2 <20:
110+
print(number_words[hundreds_digit] + "-hundred-" + number_words[tens_digit2])
111+
112+
else:
113+
print(number_words[hundreds_digit] + "-hundred-" + number_words[tens_column2] + "-" + number_words[ones_digit])
114+
elif ones_digit == 0:
115+
print(number_words[ten_column])
116+
elif number < 20:
117+
print(number_words[number])
118+
else:
119+
print(number_words[ten_column] + "-" + number_words[ones_digit])

code/matt/python/lab01-mean.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)