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
trapecia [35]
3 years ago
10

#Write a function called get_integer that takes as input one #variable, my_var. If my_var can be converted to an integer, #do so

and return that integer. If my_var cannot be converted #to an integer, return a message that says, "Cannot convert!" # #For example, for "5" as the value of my_var, get_integer would #return the integer 5. If the value of my_var is the string #"Boggle.", then get_integer would return a string with the #value "Cannot convert!" # #Do not use any conditionals or the type() function.
Computers and Technology
1 answer:
DiKsa [7]3 years ago
6 0

Answer:

#here is function in python

#function that return integer if input can be converted to int

#if not it will return a string "Cannot converted!!"

def get_integer(inp):

   try:

       return int(inp)

   except:

       return "Cannot convert!!"

print()

#call the function with different inputs

print(get_integer("5"))

print(get_integer("Boggle."))

print(get_integer(5.1))

print()

Explanation:

Define a function get_integer() with a parameter.In this function there is try  and except.First try will execute and if input can be converted to integer then  it will convert it into integer and return it.If it will not able to convert  the input into integer then except will return a string "Cannot convert!!".In the function get_integer(), there is no use of any conditionals or type function.

Output:

5

Cannot convert!!

5  

You might be interested in
What statement would you use to print the phrase Hello, world and then start a new line?
tangare [24]

Answer:

Statement to print phrase "Hello, world" and then start a new line in java.

System.out.println("Hello, world");

Explanation:

In java, we use "System.out.println();" statement to print any string/phrase and then start a new line.The above line will print phrase "Hello, world" and then start a new line.

Implementation in java:

// class definition

class Main

{

// main method of the class

public static void main (String[] args)

{

// statement to print phrase and start new line

      System.out.println("Hello, world");  

} }

7 0
3 years ago
Describe two methods by which viruses can spread.
vlada-n [284]

Answer:

the two methods that can spread viruses are touching and breathing

Explanation:

When there are viruses being spread breathing near another person can caused it to spread because viruses can travel through air. if the viruse is in your systems coming out through the mouth is one way it can travel to another person. That's why wearing a mask is helpful

The other was is touching. Viruses can travel through physical contact. Is hands arent being wash regularly after eating brushing teeth etc it leaves germs and bacteria which is some of the ways and sometimes the main reason as to how viruses are made or created. That's why washing hands are important

Hope's this helps

6 0
2 years ago
Wats is a internal disk drive​
NikAS [45]

Answer: Internal disk drive is the main storage device located in a computer. It usually contains software applications, the operating system and other files.

Explanation:

3 0
3 years ago
Read 2 more answers
According to the semantic network model, it would take less time to answer "true" to which sentence?
-Dominant- [34]

Answer:

The answer is "salmon is a fish".

Explanation:

In the given question some information is missing, that is the option of the question, which can be described as follows:

a) salmon is a fish.

b) salmon is an animal.

c) canary is an animal.

d) They all take a certain amount of time.

The Semantic Network Model is the network model, that uses the data nodes, which are connected by negative and positive links with one another. It permits their memory to retrieve ready related data, that's why in this question option a is correct, and other choices were wrong, that can be defined as follows:

  • In option b, It's not a animal, it is a salt-water fish.
  • In option c, It is a bird, that's why it is wrong.
  • In option d, When we read-option a, it takes less time to read, that's why it is wrong.

5 0
3 years ago
What is green market?
Fynjy0 [20]
Green marketing<span> is the </span>marketing<span> of products that are presumed to be environmentally preferable to others.Thus </span>green marketing<span> incorporates a broad range of activities, including product modification, changes to the production process, sustainable packaging, as well as modifying advertising.</span>
4 0
3 years ago
Other questions:
  • Write an expression that executes the loop body as long as the user enters a non-negative number.Note: If the submitted code has
    11·1 answer
  • Type the correct answer in the box spell all words correctly
    8·1 answer
  • What type of cable is used to connect a workstation serial port to a cisco router console port?
    15·1 answer
  • Which of the following is not a metamorphic agent?
    8·2 answers
  • How do governments correct for negative externalities?
    5·1 answer
  • 5 negative impacts of digital life Explain
    9·1 answer
  • What are registers in ICT used for?
    5·1 answer
  • 7.5 Code practice Plz answer ASAP
    15·1 answer
  • Which of the following IS an operating system? *<br> Reddit<br> Ubuntu<br> Office 365<br> Mac Pro
    9·1 answer
  • Noah is creating a startup. He uses the website Upwork to hire freelancers in India and in the Ukraine to work for him. This is
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!