Module 2: Python Fundamentals
In the picture above, it shows the code I wrote for this module running and working. The first line displays my last name. The lines under that is a dice game from pre-written code that I had to figure out the two errors in the code in order for the game to work properly. It rolls some dice and lets you know if you win, lose, or tie.
The list underneath the dice game in the first picture is a randomized list the spits out 20 random numbers between 0 and 10. The flow chart for this code is located in the picture above. The code for this only goes to the first instance of print(luckyList). The rest of the flow chart displays the rest of the code for the last list in the first picture. This code removes a chosen integer (I choose 7) and will print out how many times the chosen number will be removed from the list. It then prints out the new list with the chosen integer removed from the list.
Notes:
1
Import math and random should be at the top
of code to work correctly.
2
Indexing is very useful to find certain
words or letters in a statement.
3
Breaks can end loops when they reach certain
conditions designated in your code.
4
Str(var)+, +str(var)+ is how to add strings
to statements that hold variables.