Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Python coding help
12-01-2015, 06:09 PM #1
- Join Date
- Nov 2015
- Thanked 0 Times in 0 Posts
Python coding help
Begin a new
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
function to perform
Watch and follow along with this video to learn how to
flowchart the logic of a
The program should t
hen display the output on the screen, and in a file called
12-01-2016, 10:24 AM #2
- Join Date
- Nov 2016
- South Africa, Cape Town
- Thanked 1 Time in 1 Post
Lol for the video...
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()