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
pochemuha
3 years ago
8

PYTHON

Computers and Technology
1 answer:
Nina [5.8K]3 years ago
4 0

Answer:

This is one of the efficient ways to find the number of occurrences of a given number in a list:

<h3><u>def find_num(arr,n):</u></h3><h3><u>    return len([count for count in arr if count == n])</u></h3><h3><u>print(find_num([0,1,1,1,0],1))</u></h3>

If you want a simpler version, you can try this:

<h2><u>def find_num(arr,n):</u></h2><h2><u>    count = 0 </u></h2><h2><u>    for i in range(len(arr)): </u></h2><h2><u>        if arr[i]==n: </u></h2><h2><u>            count += 1 </u></h2><h2><u>    return count</u></h2><h2><u>print(find_num([0,1,1,1,0],1))</u></h2>

This is the simplest method:

<h2><u>arr = [0,1,1,1,0]</u></h2><h2><u>print(arr.count(1))</u></h2>

I think I gave you enough examples. This should get you started off easily.

If you need an explanation, I am happy to help you. BTW I started python 6 months back so even I am pretty new to this.

You might be interested in
What is the top folder of the file tree called
m_a_m_a [10]
The root directory, or root folder, is the top-level directory of a file system.
3 0
3 years ago
Read 2 more answers
Home communication involves controlling systems such as heating, cooling, and security.
katen-ka-za [31]

Answer:

<em>A. True</em>

Explanation:

<em>Home communications involves automating home. It includes controlling the air-con,water heater, webcam, etc. A</em>

6 0
3 years ago
What are personal skills?
jok3333 [9.3K]

Answer:

Basically what you are good at

Explanation:

5 0
4 years ago
explain the joke, “There are 10 types of people in the world: those who understand binary and those who don’t.”
tino4ka555 [31]

Answer:

Binary is made up of only 2 digits: a one and a zero. 1011 is eleven in our counting system.

So 10 in binary = 2 in our counting system.

Read the joke as follows. There are 2 types of people in the world: those who  understand binary and those who do not.

I guess it's not really that funny, but computer programmers like it.

6 0
1 year ago
How would you create a tint of a color?
svetlana [45]
D. white with a hue
HOPE THIS HELPS
5 0
3 years ago
Other questions:
  • What part of the computer gives access to the internet
    10·1 answer
  • Why does my hp computer keep freezing when i move it?
    10·1 answer
  • A binary message consisting of four bits was sent to you by a friend. The message was supposed to be ABAB. Unfortunately, your f
    8·1 answer
  • Lesley wants to develop web pages. Which of these programming languages is useful in the context of web design?
    14·1 answer
  • What should be done with statements or sections which are unclear?
    12·2 answers
  • Answer the queston...........​
    7·2 answers
  • Consider the following class definition.
    7·1 answer
  • Is there a way of how to delete this if so pleas tell me
    11·1 answer
  • Take two String inputs of the same length and merge these by taking one character from each String (starting with the first ente
    8·2 answers
  • Which of the following is the key business objective behind the technologies implemented by PCL Construction, as discussed in th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!