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
A developer of a relational database refers to a file as a
goldenfox [79]
This is the correct Answer    <span>Attribute</span>
5 0
3 years ago
Did y’all enjoyed project next phase 3 and The 4 revamped heroes
ryzh [129]

Answer:

it was good i liked it

Explanation very good

4 0
3 years ago
What is text formatting?​
Ede4ka [16]

Answer:

Formatting text is the text that is displayed in a specified style. This refers to how text appears in your document. This includes the size, color, and font of the text.  

examples: text <em>text </em><u>text</u>

3 0
3 years ago
Read 2 more answers
I WOULD REALLY APPRECIATE IT IF YOU ANSWER THIS QUESTION: Which of the following devices transforms electrical energy into mecha
sammy [17]

Answer:

Pencil shapener

Explanation:

7 0
3 years ago
Which of the following functions and expressions will convert the ASCII character "Z" to its numeric equivalent ASCII code?
professor190 [17]

Answer:

The answer is "Option a"

Explanation:

In Python, ord() function takes the length string 1 as a parameter and returns the representation of the passed argument for the Unicode point. For example, ord('Z') return value 90 that is a Unicode code value of character 'Z'. and other function is not correct that can be described as follows:

  • In option b, Inside the ord function chr function is used that accepts only numeric value that' why it is not correct.
  • In option c, Inside the chr function ord function is used that cover value in lower case that's why it is not correct.
  • In option d, The chr function accepts only numeric value that's why this option is not correct.

3 0
4 years ago
Other questions:
  • Some personal computer manufacturers provide a hard disk configuration that connects multiple smaller disks into a single unit t
    6·1 answer
  • It is important to ____ the line in the code editing window in the exact location where you want to insert a code snippet to pro
    10·1 answer
  • The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IE
    6·1 answer
  • Write a program that will compare two names. The program prompts the user to enter two names for a comparison. If the names are
    8·1 answer
  • _________ cards contain a chip that can store a large amount of information as well as on a magnetic stripe for backward compati
    12·1 answer
  • Wendy had been searching the internet for a great deal on jewelry. While looking at one site, a pop-up was displayed that told h
    11·1 answer
  • Complete the sentence.
    8·2 answers
  • You are adding more features to a linear regression model and hope they will improve your model. If you add an important feature
    7·1 answer
  • How many passes will it take to find the five in this list?
    6·2 answers
  • WILL GIVE BRAINLIEST!!! PLEASE HELP!!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!