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
It is easier to make an object move across the screen by using the tweening function rather than creating each individual frame
Vesna [10]
Uhhhh I believe it’s true if it’s wrong I’m srry ....
3 0
3 years ago
Help me, please! No links btw :)
Nikolay [14]

Answer:

c im trying my best sorry if you get it wrong

Explanation:

7 0
3 years ago
Read 2 more answers
The software that controls the computer hardware and establishes standards for developing and executing applications best descri
victus00 [196]
An operating system such as windows or macos
4 0
4 years ago
What does no technical solution problems mean answers?
Lena [83]
Solve the problems to make every thing work perfect
4 0
3 years ago
How can a company that collects and uses private customer data ensure it will move forward in a sustainable culture of privacy?
Len [333]

Answer:

I think that it is c and if not pls take the point

back

4 0
3 years ago
Other questions:
  • Speaker,printers, and monitors are all considered what?
    10·2 answers
  • Which logic gate produces an output of 1 only if both it’s inputs are 0?
    10·2 answers
  • Write a method swaparrayends() that swaps the first and last elements of its array parameter. ex: sortarray = {10, 20, 30, 40} b
    15·1 answer
  • What two names are used to describe the configuration in which internal and ​external dns queries are handled by different dns s
    13·1 answer
  • What type of formatting does the clip below demonstrate
    6·1 answer
  • The three devices you are going to install are a 2u server, a 1u keyboard tray, and an 8u space for a rack mounted moitor. Given
    6·1 answer
  • You have a notebook computer and wish to connect to an IEEE 802.11n wireless network. The computer does not have a built-in wire
    11·1 answer
  • Encryption is the key to keeping your personal information secure online.<br><br> True<br><br> False
    11·1 answer
  • How does social media help?<br><br>i will give you the brainliest​
    13·2 answers
  • _________ in online education refer(s) to how fairly the particular needs of particular groups of students are met.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!