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
tangare [24]
3 years ago
7

Write a function called is_present that takes in two parameters: an integer and a list of integers (NOTE that the first paramete

r should be the integer and the second parameter should be the list) and returns True if the integer is present in the list and returns False if the integer is not present in the list. You can pick everything about the parameter name and how you write the body of the function, but it must be called is_present. The code challenge will call your is_present function with many inputs and check that it behaves correctly on all of them. The code to read in the inputs from the user and to print the output is already written in the backend. Your task is to only write the is_present function.
Computers and Technology
1 answer:
Agata [3.3K]3 years ago
7 0

Answer:

The function in python is as follows

def is_present(num,list):

    stat = False

    if num in list:

         stat = True

       

    return bool(stat)

Explanation:

This defines the function

def is_present(num,list):

This initializes a boolean variable to false

    stat = False

If the integer number is present in the list

    if num in list:

This boolean variable is updated to true

         stat = True

This returns true or false        

    return bool(stat)

You might be interested in
Why is time management considered a soft skill
FinnZ [79.3K]
This is due to the simple fact that time management helps you not only get things done for yourself, but also not get in the way of others and let them get things done for themselves. It's like working in harmony.

Hope this helps! <3
5 0
3 years ago
Read 2 more answers
Write a loop that reads positive integers from console input, printing out those values that are even, separating them with spac
AfilCa [17]

#include <iostream>

#include <vector>

std::vector<int> v;

int main(int argc, char* argv[]) {

   while(1) {

   int temp;

   std::cout << "\nEnter a number: ";std::cin>>temp;

   

   if(temp<0) {

       std::cout << "\nEven number(s) is/are:\n---------------------\n";

       for(int i=0;i<v.size();i++) {

           if(v.at(i)%2==0) std::cout << v[i] << " ";

           else continue;

       }

       std::cout << std::endl;

       break;

   }else {

       v.push_back(temp);

   }

}

   return 0;

}

3 0
2 years ago
What is presentation
Gelneren [198K]
To present something infront of a crowd
5 0
2 years ago
Read 2 more answers
0111101101010110101110110001001011101001011101101010101010110101
rodikova [14]

Answer:

binary digits in computer system it belongs

4 0
3 years ago
Containers for contaminated sharps must have several characteristics. What’s missing from the list? PuContainers for contaminate
Nadya [2.5K]
All sharps containers must be stored upright,be puncture-resistant, be labeled or color-coded red & leakproof on both the sides & the bottom! The last one is the one missing!
4 0
3 years ago
Read 2 more answers
Other questions:
  • Why ois my printer not printing pictjures?
    9·1 answer
  • As yall know its spoopy season. This means spoopy music! I am having a live stream on the Spoon app under the username teendrago
    11·1 answer
  • In the Remote Access Domain, if private data or confidential data is compromised remotely, you should set automatic blocking for
    5·1 answer
  • When does information become a liability for an organization
    6·1 answer
  • What are interpersonal skills?
    12·2 answers
  • A new employee has reported that print jobs are printing as garbled text. Which of the following is MOST likely the reason for t
    8·1 answer
  • Write a program that asks the user to enter two integer numbers X and Y. The program halves each number between X and Y then pri
    15·1 answer
  • Which cable standard is a standard for newer digital cable, satellite, and cable modem connections?
    11·1 answer
  • Which option on the Format tab is used to modify particular portions of the chart?
    13·1 answer
  • Which statement is true about the energy of electromagnetic radiation?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!