Programming

This year, as a Sophomore, I am taking a Programming 1 class at Lincoln Lutheran. So far I enjoy doing it, but there are a lot of times that I do find myself struggling to work through a problem, which is understandable since it’s something completely new that I am learning. We are learning a lot of things in Programming, and it is going really fast, but I think that it is a good pace to be learning for this class. I think if it was any slower it would start to get a bit boring and uninteresting, so I’m glad it’s the speed that it is and that I decided to take the class.

One of the programs that we have done as an assignment is to program a distance conversion
This program will ask which unit you wish to convert to and from. The options are Miles to Nautical Miles, Miles to Kilometers, Kilometers to Nautical Miles, Nautical Miles to Kilometers, and Kilometers to Miles. the program will also give a recommendation for a form of travel to go that distance.
I am proud of this program because of how much work I put into it for it to work and that I was able to create something like this and make it work how it was supposed to.

While I was making this program, some things that were difficult were on the technical side of things. I had tried to give it the ability to print out the words slowly rather than print everything all at once, but in doing that I wasn’t able to use the float function, so the actual point of the project was failing at the expense of having the program look nice. I ended up having to dispose of the “slow_print” that I was using since I needed my program to actually convert the distance (since that was the whole point of the program).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def convert_distance(unit,distance):
    #
    # Convert the distance from one unit into the other unit
    #
    if unit == "1":
        distance = float(distance)
        newDistance = distance / 1.151
    elif unit == "2":
        distance = float(distance)
        newDistance = distance * 1.151
    elif unit == "3":
        distance = float(distance)
        newDistance = distance / 1.609
    elif unit == "4":
        distance = float(distance)
        newDistance = distance * 1.609
    elif unit == "5":
        distance = float(distance)
        newDistance = distance / 1.852
    elif unit == "6":
        distance = float(distance)
        newDistance = distance * 1.852
    return(newDistance)

Above is a little part of the code for the distance conversion program. This part of the program is converting the unit of distance. The function convert_distance is calling in unit and distance from previous functions where they were assigned and is returning newDistance into main for it to be used later on in the program and eventually given to the user.

This is a run-through of the program. This is changing 90 miles into kilometers (144.84 km).

We are still very new to programming and haven’t done very much, but I’m looking forward to the rest of this semester’s learning, and I can’t wait to see how much that I have improved from this program!

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments

  • Margie Main on Solar EclipseVery well done! So descriptive that I almost didnt need the pic!