Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a python program that will simulate the NJ Cash 5 lottery. The program mus

ID: 3816467 • Letter: W

Question

Write a python program that will simulate the NJ Cash 5 lottery.

The program must pick 5 numbers from 1 to 38 - No duplicates allowed

It must print these numbers side by side on one line under the heading "These are the cash 5 numbers."

You will need to "import random" at the beginning of your code similar to the challenge at the end of chapter 5

After selecting the 5 numbers, ask the user if they want to play again and allow them to do so.

This will require nested loops and lists (arrays).

I need help with this code.

Explanation / Answer

# paste bin link for code with indentation: https://pastebin.com/NwBAQPnw

import random
def get_nj_lottery_numbers():
return random.sample(range(1, 39), 5)

def play_nj_cash_5_lottery():
lottery_num = get_nj_lottery_numbers()
print("These are the cash 5 numbers: "),

for num in lottery_num:
print(num),
print("")

def main():
while(True):
play_nj_cash_5_lottery()
playAgain = raw_input("Play again? Yes/No : ")
if playAgain.lower() == "no":
break

if __name__ == "__main__":
main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote