Skip to content

Commit b7cb80f

Browse files
committed
Merge branch 'kacey-lab03-number-phrases' of https://github.com/PdxCodeGuild/class_HB2 into kacey-lab03-number-phrases
2 parents fff3da4 + e8295c3 commit b7cb80f

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

1 Python/labs/02 Unit Converter

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Ask the user for the number of feet, and print out the equivalent distance in me
66

77
> what is the distance in feet? 12
88
> 12 ft is 3.6576 m
9-
109
Version 2
1110
Allow the user to also enter the units. Then depending on the units, convert the distance into meters. The units we'll allow are feet, miles, meters, and kilometers.
1211

@@ -19,23 +18,21 @@ Below is some sample input/output:
1918
> what is the distance? 100
2019
> what are the units? mi
2120
> 100 mi is 160934 m
22-
23-
> Version 3
24-
> Add support for yards, and inches.
21+
Version 3
22+
Add support for yards, and inches.
2523

2624
1 yard is 0.9144 m
2725
1 inch is 0.0254 m
28-
2926
Version 4 - optional
3027
Now we'll ask the user for the distance, the starting units, and the units to convert to.
3128

3229
You can think of the values for the conversions as elements in a matrix, where the rows will be the units you're converting from, and the columns will be the units you're converting to. Along the horizontal, the values will be 1 (1 meter is 1 meter, 1 foot is 1 foot, etc).
3330

34-
ft mi m km
35-
ft 1 0.3048
36-
mi 1 1609.34
37-
m 1/0.3048 1/1609.34 1 1/1000
38-
km 1000 1
31+
ft mi m km
32+
ft 1 0.3048
33+
mi 1 1609.34
34+
m 1/0.3048 1/1609.34 1 1/1000
35+
km 1000 1
3936
But instead of filling out that matrix, and checking for each pair of units (if from_units == 'mi' and to_units == 'km'), we can just convert any unit to meters, then convert the distance in meters to any other unit.
4037

4138
Furthermore you can convert them from meters by dividing a distance (in meters) by those same values used above. So first convert from the input units to meters, then convert from meters to the output units.
@@ -45,11 +42,10 @@ Below is some sample input/output:
4542
> what is the distance? 100
4643
> what are the input units? ft
4744
> what are the output units? mi
48-
> 100 ft is 0.0189394 mi
49-
50-
<!-- > Turning in your lab
51-
> Make sure you are still on your lab branch with git status. This will also show you a list of files that have been modified.
52-
> Add any files you want git to keep track of using git add filename. Replace filename with the name of your file. You can also use git add . to add everything within the current folder.
53-
> Commit your work using git commit -m "Your commit message". Make sure your commit message is descriptive and describes what has been changed during this commit.
54-
> Finally we can run the command git push to send our files up to Github. This may throw an error, but worry not, there will be a suggested command to run, simply copy and paste that command and you should be good to go.
55-
> Don't forget to visit Github and create a pull request to submit your work for review. -->
45+
100 ft is 0.0189394 mi
46+
Turning in your lab
47+
Make sure you are still on your lab branch with git status. This will also show you a list of files that have been modified.
48+
Add any files you want git to keep track of using git add filename. Replace filename with the name of your file. You can also use git add . to add everything within the current folder.
49+
Commit your work using git commit -m "Your commit message". Make sure your commit message is descriptive and describes what has been changed during this commit.
50+
Finally we can run the command git push to send our files up to Github. This may throw an error, but worry not, there will be a suggested command to run, simply copy and paste that command and you should be good to go.
51+
Don't forget to visit Github and create a pull request to submit your work for review.

code/kaceyb/python/lab02/lab_02.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# VERSION 1 #
55

66

7-
from inspect import formatannotation
7+
88

99

1010
conversion_list = {
@@ -131,4 +131,4 @@
131131
print(f"{users_distance_input} {users_unit_input} is {result}")
132132

133133
user = False
134-
134+

0 commit comments

Comments
 (0)