Open comments for this post
Handling Errors for Input
Today I created options if the user typed in wrong data, they could change it. I also created options if the user typed in something that was not supposed to be typed, an error message would appear.
Program running
- Now the program runs forever until you type exit
- The program always clears the terminal when a new question comes and prints “NASA-Missions” at the top
- I made the program run forever by using while loop
Error Handling
- When users types in an option not in the options, the program shows an error message
- If the user types in data, the program asks the user for confirmation. If the user says no, the user can change the data.
Learned
- Learned about While loops
- learned about how continue and break work
- also learned the .lower() method
Took a very long time, and used a lot of if/elif/else statement. You can see in the picture just a glimpse of the hundreds of if/else.
Open comments for this post
Created option for Moon
Now you can choose between a planet and a moon. The program asks the user input for these things:
- moon name
- mission name
- gravity
- extra info
Then this is stored into a dictionary. Then this puts the data into an excel spreadsheet.
Improvements
I still need to ask the user for the distance of the planet/moon from earth. Then I can calculate the fuel needed to get there.
Maybe use SQL for data?
The user of dictionaries helped a lot in this program. Now I fully understand how it works.
Open comments for this post
Min/Max function
Made a new function that finds the minimum and maximum of the data.
How it works
- The program asks the user to type 0 or 1 for min/max
- The program uses a for loop and goes through each row finding the maximum and minimum or what the user chose.
- In each cell in the sheet, the program checks if that cell is less/greater than the current min/max using the min()/max() function.
- The function then returns a tuple of the price of the product that was the min/max and the name of that product.
- The result is printed using a formatted string.
Debugging
While creating the function, there was some errors with the if statement.
-
The if statement checks if the user typed 0 or 1, but the user input was not converted into an int. So the min max function was skipped.
-
The function started to return the minimum price but the name of that product was different.
-
The fix was simple - there was an if statement that checked if the min/max was the current cell but the part where it assigns the product_name was not indented, so it was out of this if statement
-
Had a few errors with unpacking, but the changes were made to fix it
Open comments for this post
Day 1 of Race Countdown Game
This is my first hardware project
LEDs
- LED starts as a countdown, so each light represents a number counting down from 3
- Example: red represents 3, yellow, represents 2…
Connected the LEDs to the breadboard and used 220 ohm resistors. Then I connected the breadboard jumper wires to the I/O pins.
The Ultrasonic
My idea is that a person will start the game and there will be a countdown. This game will be a reaction game. The person will put their car behind the ultrasonic sensor.
If the person launches the car after the green, they win, but if they do it to early, they lose.
Display Module
- Shows 3, 2, 1
- Shows you lost or won
- the shows your reaction time
Need to create more code to use display and sensor
Open comments for this post
Created a new project and allowed user to create a new mission and set some key values for the mission.
Open comments for this post
Now users can type in letters that represent each column instead of typing numbers