In this week's assignment, I learned about different types of objects and some functions that can be applied to these objects. To illustrate that, I created a string of my full name. Next, I converted the string into a list with each name as a single item in the list. Lastly, I used indexing to return only my last name.
In addition, I practiced debugging skills by correcting the errors in the code for a dice game. Through this exercise, I was able to get acquainted with the steps to take when my code is giving me errors. Using the clues given in the error codes, I was able to look up solutions in the textbook and online, so that the dice would run properly.These were my results once the code was updated!
Lastly, I had to apply what I had learned about the different types of objects, various functions in python, debugging, with/for loops, and if/else statements to generate a list of randomly generated number and remove an unlucky integer. Initially, I had difficulty with my syntax, so the code that I created was giving me syntax errors. Once I resolved those issues, I was able to generate the necessary output.
I started by importing the random module to help with the random number generation that would come later. Then, I created a list with no items called luckyList. Next, I used a while statement to indicate that while luckList contained less than 20 items (using the len function) another random number between 0-10 should be appended to the list. Then, I used an if statement to indicate that if the luckyList contained 20 items, then the luckyList should be printed

No comments:
Post a Comment