1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
V125BC [204]
3 years ago
10

A lottery ticket contains five unique numbers. A set of unique numbers does not contain repeated elements. The winning combinati

on of this lottery is chosen by picking five unique numbers. Define a function matches(ticket, winners) that takes two lists and returns an integer that says how many numbers the two lists have in common.
Computers and Technology
1 answer:
RSB [31]3 years ago
6 0

Answer:

Answer explained below

Explanation:

I have given two approaches in implementing the solution.

1. Using the for loop, in which you have to iterate over all the elements in list 1 and check in list 2

2. Use the set intersection method. As intersection will give u the common elements. And we can get there length by using len method.

I have added the code along with the snapshot and inline comment for the ease of you to understand. Please check the methods below. You can use either of them.

METHOD-1:

********** CODE *****************

def matches(tickets,winner):

tickets = set(tickets)

winner = set(winner)

counter = 0 #To Count the common elements

for i in tickets: # Iterate over all the elements in tickets.

if i in winner: # Check the element in the winner list

counter = counter+1

return counter

METHOD -2:

********** CODE ********************

def matches(tickets, winner):

tickets = set(tickets)

winner = set(winner)

return len(tickets.intersection(winner))

You might be interested in
Why the computer is known as versatile and diligent device ? explain.<br>​
Scrat [10]

Answer:

Computer is called versatile and diligent device because it is used in almost all the fields for various purposes and it can perform the task repeatedly without loosing its speed and accuracy for long time.

5 0
2 years ago
___operating space means there is a restriction to the drivers line of sight
Harman [31]

Answer

Closed zone operating space means there is a restriction to the drivers line of sight

Explanation

The line of sight restriction to a driver or while driving is the visible path of travel from your vehicle to your targeted area towards your destination.It is also the area that's visible to a driver while driving.

Closed zone or condition means that there is a restriction to the drivers view or that the space is unavailable in a particular zone.

5 0
3 years ago
Recall the CFG G4 that we gave in Example 2.4. For convenience, let’s rename its variables with single letters as follows. E → E
dimaraw [331]

Answer:

Check the attached image

Explanation:

the diagram for explaning all the solutions is in the attaged images below.

6 0
3 years ago
WHAT ARE THE CONTENTS THAT WE SHOULD USE FOR THE PRESENTATION OF DIGITAL WORLD
Lana71 [14]

Answer:

Introduction

Importance

Advantages

Disadvantages

Effects

Conclusion

8 0
3 years ago
If a student passes off an author’s work as his or her own, the student has
Taya2010 [7]
Plagiarism is the answer
7 0
3 years ago
Other questions:
  • Which view is used to allow a publisher to view facing pages of a publication at the same time?  NormalMaster PageTwo-Page Sprea
    9·1 answer
  • One problem with using e-mail is that ______. a. It can be perceived as being too casual b. It is never appropriate for business
    12·1 answer
  • All objects in an object-oriented program are instantiated (created) from a ____.
    12·1 answer
  • Which hypervisor works on older pcs without hardware virtualization support?
    9·2 answers
  • Path of the signal of television
    6·1 answer
  • Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a
    10·1 answer
  • A bank is experiencing a DOS attack against an application designed to handle 500IP-based sessions. In addition, the perimeter r
    11·1 answer
  • The large capacity, high-definition optical discs designed to store hi-def video and video games are _______. Group of answer ch
    13·1 answer
  • You text file begins with the following rows. The pattern is a description of the item to be repaired, its color, and the issue.
    14·1 answer
  • Which blu-ray standard defines rewritable disks?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!