2nd part of the assignment 1. Write a program that determines whether all the in
ID: 3778744 • Letter: 2
Question
2nd part of the assignment
1. Write a program that determines whether all the input numbers cover 1 to 99. (Submit it as Lastnamel.py through DropBox.) Each ticket for the Pick-10 lotto has 10 unique numbers ranging from 1 to 99. Suppose you buy a lot of tickets and like to have them cover all the numbers from 1 to 99. Write a program that reads the ticket numbers from a file and determines whether all numbers are covered. Assume the last number in the file is 0. Suppose the file contains the following numbers 80 3 87 62 30 90 10 21 46 27 12 40 83 9 39 88 95 59 20 37 80 40 87 67 31 90 11 24 56 77 11 48 51 42 874 1 41 36 53 52 82 16 72 19 70 44 56 29 33 54 64 99 14 23 22 94 79 552 60 86 34 4 31 63 84 89 778 43 93 97 45 25 38 28 26 85 49 47 65 57 67 73 69 32 71 24 66 92 98 96 77 6 75 17 61 58 13 35 81 18 15 5 68 91 50 76 Your program should display The tickets cover all numbers
Explanation / Answer
# In part1 ,Please change the file path before running the program
#Part 1
''' LastName1.py'''
x1=[]
with open('/home/naresh/Desktop/chegg/1.txt') as f:
for line in f:
if line[0] != '0':
x1.append([int(y) for y in line.split()])
x2 = set([item for sublist in x1 for item in sublist])
if len(x2) == 99:
print("All the numbers from 1 to 99 are covered")
else:
print("Some numbers are missing, All the numbers from 1 to 99 are not covered")
''' LastName2.py'''
#Part 2
dict1 = {'0':'Ace','1':'2','2':'3','3':'4','4':'5','5':'6','6':'7','7':'8','8':'9','9':'10','10':'Jack','11':'Queen','12':'King'}
deck = list(range(52))
l1=[]
import random
random.shuffle(deck)
l1.append(deck[0])
l1.append(deck[13])
l1.append(deck[26])
l1.append(deck[39])
for val in l1:
if val // 13 == 0:
x = val % 13
print("Card Number" + ' ' + str(val) + ' ' + "is the" + ' ' + dict1[str(x)] + ' ' + "of spades")
elif val // 13 == 1:
x = val % 13
print("Card Number" + ' ' + str(val) + ' ' + "is the" + ' ' + dict1[str(x)] + ' ' + "of hearts")
elif val // 13 == 2:
x = val % 13
print("Card Number" + ' ' + str(val) + ' ' + "is the" + ' ' + dict1[str(x)] + ' ' + "of diamonds")
else:
x = val % 13
print("Card Number" + ' ' + str(val) + ' ' + "is the" + ' ' + dict1[str(x)] + ' ' + "of clubs")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.