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
Which computer can be used where there is no regular electricity?​
alina1380 [7]

Answer:

A mechanical computer

Explanation:

Created from gears and levers

7 0
2 years ago
Show the steps of a Selection Sort for the numbers ( 5 3 9 5 ).
Sedbober [7]

Answer:

Sorted array will be:-

3 5 5 9

Explanation:

In Selection Sort algorithm it sorts the array by repeatedly finds the minimum in the array form the array that is unsorted and swaps it with the value at the first position.

The unsorted array:- 5 3 9 5

In first iteration

minimum is 3.

3 will be swapped with 5.

Now the array is 3 5 9 5

sorted array 3

In second iteration

unsorted array is 5 9 5

sorted array 3 5

and the minimum from it is 5

No swapping will occur.

In third iteration

unsorted array is 9 5

minimum is 5

sorted array 3 5 5

swap it with 9.

Now the array is sorted.

3 5 5 9

3 0
3 years ago
Select the correct navigational path to set the name for a cell range.
S_A_V [24]

Answer: formula tab, defined names, name manager

Explanation:

ed 2020

6 0
3 years ago
Read 2 more answers
Which is the most used operating system? A. Windows B.Linux C.Leopard D. DOS
Neko [114]
I think it´s either A. or  B.
7 0
3 years ago
Read 2 more answers
In 4-bit two's complement representation, what is the binary encoding of the number -5?
Katena32 [7]

Answer:

a) 1011

Explanation:

In 4 bit two's complement representation, the first bit is the sign bit.

If the sign bit is 1, the number is negative.

If the sign bit is 0, the number is positive.

What is the magnitude of the sign bit?

In n-bit two's complement representation, the magnitude of the sign bit is:

2^{n-1}-1

So, in 4-bit two's complement representation, the magnitude of the sign bit is:

2^{4-1}-1 = 8

Since the number is negative, the value of this bit is -8.

The other bits are magnitude bits, positive.

We have that the sum of these bits must be -5, and we already have -8. So what should be the value of these last 3 bits?

First, i am going to solve this equation to find the decimal value of the last three bits.

-5 = -8 + x

x = 3

So, the last three bits are:

3_{10} = (011)_{2}

The binary encoding of the number -5 is:

a) 1011

5 0
3 years ago
Other questions:
  • When you first open office calc, the most recently saved spreadsheet opens up. A) true B) false
    14·1 answer
  • Which subject area describes collecting and analyzing data from computer systems, networks, and storage devices, as part of an i
    7·1 answer
  • When RadioButton objects are contained in a group box, the user can select only one of the radio buttons on the panel.
    12·1 answer
  • ) How many switching functions of two variables (x and y) are there?
    11·1 answer
  • You use a cisco 2900 router in your network. you are considering purchasing and implementing the Unifield communications feature
    8·1 answer
  • Clive wants to write a query that will display the names of the students who scored less than 10 in their final exams. Which num
    8·2 answers
  • _______________ is a computer networking protocol used by hosts to retrieve IP address assignments.
    11·1 answer
  • Para ti que es el sexting​
    11·1 answer
  • The average American has 10 devices, ask for users average number of devices. Any number between 7 and 12 will print “you have a
    13·1 answer
  • Convertbinary(111100)to decimal​​​​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!