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
The part of the computer that provides access to the Internet is the
andrew11 [14]

Answer:

MODEM

Explanation:

5 0
3 years ago
Why you chose BSIT?​
chubhunter [2.5K]

Answer:

Because of choice.

Explanation:

meaningful Question py

6 0
4 years ago
Read 2 more answers
Amelia is going to school to get a degree in Early Childhood Education. She wants to open her own daycare after she graduates. W
Yanka [14]
She could volenteer at a day care at the weekend or study child development/care whilst she is still at school.
8 0
3 years ago
Swiping and pinching are graphical user interface (gui) _____________.
Sergeu [11.5K]
Swiping and pinching are graphical user interface (gui) to zoom in or zoom out.  <span>One of the many multitouch gestures on today's laptops is the ability to </span>pinch<span> two fingers to </span>zoom<span> in and </span>out<span> in a window. </span>
6 0
4 years ago
Read 2 more answers
How to get a javascript's varible
Kamila [148]

Answer:

If you want to use a js variable in a php script you MUST pass it within a HTTP request. There are basically two ways: Submitting or reloading the page.

Explanation:

In programming, just like in algebra, we use variables in expressions (total = price1 + price2). From the example above, you can calculate the total to be 11. JavaScript variables are containers for storing data values. All JavaScript variables must be identified with unique names. These unique names are called identifiers.

8 0
2 years ago
Other questions:
  • Which passage form the passage best contributes to elisa impatient tone
    8·1 answer
  • Lief wants to keep the information of his chart, but he doesn’t want it taking up space in his page. What should he select after
    7·2 answers
  • Lara sees her colleague taking a bribe from a customer. What should she do?
    14·2 answers
  • What 3 types of technologies are used inside hard drives?
    15·1 answer
  • John would like to move from the city into the suburbs and has been saving up a large down payment for a home. Which is the most
    7·1 answer
  • What frequency band or bands do 802.11g, 802.11a, 802.11n, and 802.11ac use?
    13·1 answer
  • Lab Assignment 3 Phase 1 Create a class named Car, which is supposed to represent cars within a Java program. The following are
    6·1 answer
  • Cuál ha sido el papel de las tecnologías de la información y los medios de comunicación en el fenómeno de la globalización​
    10·1 answer
  • You construct a simple electrical current to boil water for tea. A battery generates positive and negative charges. A wire conne
    13·1 answer
  • List out any four hardware and software components required for multimedia​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!