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
Who are the founders of video-sharing site Dailymotion?
Pavlova-9 [17]

In March 2005, Benjamin Bejbaum and Olivier Poitrey founded the Dailymotion website from the living room of Poitrey's apartment in Paris. Six individuals pooled together €6,000 ($9,271 USD) to start the business. In September 2006, Dailymotion raised funds in collaboration with Atlas Ventures and Partech International. They raised 7 million euros which was considered to be the most funds raised in 2006 from the French Web 2.0. In October 2009, the French government invested in Dailymotion through the Strategic Investment Fund. On 25 January 2011, Orange acquired a 49% stake in Dailymotion for €62 million, valuing the company at €120 million.[6]


4 0
3 years ago
Please write a code for below:
Zanzabum

Answer:

int main()  

{  

   int x,y;  

   bool b1, b2;  

   cout<<"enter values of x : ";

   cin>>x;

   cout<<"enter values of y : ";

   cin>>y;

   b1 = y > x; // false  

     

   b2 = x > y; // true  

     

   cout << "b1 is = " << b1 << "\n";  

   cout << "b2 is = " << b2 << "\n";  

     

   if (b2)  

       cout<<endl << "Larger Number" << "\n";  

   else

       cout << "Smaller Number" << "\n";  

         

     

return 0;  

}

8 0
3 years ago
BitTorrent, a P2P protocol for file distribution, depends on a centralized resource allocation mechanism through which peers are
ch4aika [34]

Answer:

yes. it is true. mark as brainlest

8 0
3 years ago
Hey yall wanna send me some just ask for my phone #
GuDViN [60]

Answer:

Send you some what?

Explanation:

the answer is 12

7 0
3 years ago
Who are the founders of Microsoft?
vekshin1

Answer:

Bill Gates, Paul Allen

Explanation:

The two founders of the mega-tech giant are Bill Gates, and Paul Allen. Hope this helps!

8 0
3 years ago
Other questions:
  • Default tab stops are set in Word every _______ inch.<br> a. ¾<br> b. 1<br> c. ½<br> d. ¼
    13·1 answer
  • Click to review the online content. Then answer the question(s) below, using complete sentences. Scroll down to view additional
    7·1 answer
  • What does raster graphic mean
    5·1 answer
  • A programmer wrote the code segment below to display the average of all the elements in a list called numbers. There is always a
    8·1 answer
  • What development in operating systems happened between the years 1990 and 2000?
    15·1 answer
  • You have been handed a mysterious piece of data by an unknown person. Judging by his shifty eyes and maniacal laughter you don't
    12·1 answer
  • A business letter is not written:
    6·1 answer
  • Liquid-liquid extraction is best suited to separate a mixture of compounds when:
    9·1 answer
  • The first cell phones in widespread use were . Smartphone technological advancements added services. Answer the following questi
    12·2 answers
  • Need help:(!!!! I’ll mark brainliest if correct
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!