Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## Python coding help

Assignment 1
6
Begin a new
Python
program
.
Create a
program
that generates numbers for a lottery ticket. The program should generate 6
random numbers from 1 to 9. Store these numbers in an array. There should not be duplicates.
You will do this by searching for each new random numbe
r in the array. If it is found, have the
computer find another number.
You will then print out the numbers in order from lowest to highest. To do this, you will
create a
function to perform
a bubble
-
sort.
Watch and follow along with this video to learn how to
flowchart the logic of a
bubble sort:
The program should t
hen display the output on the screen, and in a file called
LotteryResults.txt

2. Lol for the video...

Code:
```import random

theFile = open("LotteryResults.txt", "w")

counter = 0
numbers = []

while counter <= 5:
rand = random.randint(0, 49)
if rand in numbers:
pass
else:
numbers.append(rand)
counter += 1

print numbers
map(lambda x : theFile.write(x) , str(numbers))

theFile.close()```