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]
2 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]2 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
The _________ indicates the number of elements, or values, an array can hold
Stolb23 [73]
The size declarator indicates the number of elements, or values, an array can hold.It is used in a definition of an array.<span>The size declarator must be a constant integer expression with a value greater than zero. </span>A subscript is used to access a specific element in an array. 
8 0
3 years ago
On the food inventory worksheet, enter a function in cell G1 that counts the number of Food Items. What formula would i use!? Th
Nataly [62]

COUNT function

COUNT function determines how many cells in a range contain a number. We use this function to get the number of entries in a number field in an array of numbers. The formula one can use is G1:[…..]: = COUNT(G1:[…..])






3 0
3 years ago
2. You have noticed over the past several days that your computer is running more slowly
xenn [34]

Answer:

probably to many tabs open or take it to a shop

3 0
2 years ago
Read 2 more answers
A good machine should have the mechanical advantage of......?​
zavuch27 [327]

Answer:

The ideal mechanical advantage (IMA) of an inclined plane is the length of the incline divided by the vertical rise, the so-called run-to-rise ratio. The mechanical advantage increases as the slope of the incline decreases, but then the load will have to be moved a greater distance.

Explanation:

4 0
3 years ago
24/3*2^2/2*3+(20-10)-40
ycow [4]

Answer:

34

Explanation:

You use pemdas

8 0
2 years ago
Other questions:
  • This type of peripheral is used to interact with, or send data to, the computer.
    12·2 answers
  • The color band that represents tolerance on a resistor is the?
    11·1 answer
  • The set of communications rules for exchanging information electronically on the internet is called the ________.
    10·1 answer
  • Find the reciprocal of 7/2 × 3/5<br>​
    6·1 answer
  • Ile 1 cm<br> ?<br> 50 m<br> The an
    5·2 answers
  • Which of the following languages does not provide built-in-pattern matching operations (the language, although, has pattern matc
    14·1 answer
  • Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
    7·1 answer
  • PLEASE HELP AND FAST!!!!!<br>Which of the following devices uses binary code?
    6·2 answers
  • What is a possible weakness of an expert-novice pair?
    9·1 answer
  • When designers follow accepted standards and protocols, which of the four basic characteristics of network architecture is achie
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!