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
Pig Latin is a nonsense language. To create a word in pig Latin, you remove the first letter and then add the first letter and "
LUCKY_DIMON [66]

Answer:

Hi there  Sandrathompson5661!  

Using Java as the language for implementation, the PigLatin translation program can simply be coded as shown below. The program uses the Scanner module in java utils package to prompt the user for input of word(s) and splits the input with any of the matching delimiters. The rule to swap the first character and append it to the end with an “ay” for a normal word, or the appending of “yay” for a vowel word, is then applied. The result is printed on the screen before the program exits.

Explanation:

import java.util.Scanner;

public class PigLatin {    

 public static void main(String[] args)     {        

   char[] delimiterChars = { ' ', ',', '.', ':', ';', '\t' };        

   String[] words_array;        

   Scanner words = new Scanner(System.in);        

   System.out.println("Please enter a word (for multiple words use any of the following delimiters {' ', ',', '.', ':', ';', '\t' }): ");        

   String input_words = words.nextLine();        

   words_array = input_words.split("[,\\s\\-:.;' '\\\t]");  

   System.out.println("PigLatin translation: ");        

   for (int i=0; i<words_array.length; i++) {

     System.out.println(makePigLatin(words_array[i]));        

   }    

 }      

 public static String makePigLatin(String word)     {        

    String vowels = "aeiou";        

    if (vowels.indexOf(Character.toLowerCase(word.charAt(0))) != -1) {          

       word = word + "yay";        

    }        

    else {          

       word = word.substring(1, word.length()) + word.charAt(0) + "ay";        

    }        

    return word;      

 }

}

7 0
3 years ago
Which ribbon tab is not a default in Outlook 2016's main interface?
Verizon [17]

Answer:

review

Explanation:

4 0
3 years ago
Read 2 more answers
Top 5 best comedy or action movies.
Cloud [144]
Comedy movies you should watch is
grown ups
spider man into the spider verse
action movies you can do
like a fast and furious movie ?
some cool scary movies are
the strangers
insidious
and the serbian film :)
7 0
3 years ago
Read 2 more answers
Uhm.....why do we nessairly have to take computer classses
ASHA 777 [7]
Because in todays time and age, we're getting to more advanced technology and computers are used to usually find everything that other things did back in the day, like addresses and phone numbers, news, etc.
5 0
3 years ago
Read 2 more answers
The retention of encoded information over time is called storage. A measure of memory storage that involves identifying informat
Anni [7]

Answer: ask google and search quizlet by it , it will show you

Explanation:

7 0
3 years ago
Other questions:
  • Many programming languages require a ____ to create executable files.
    10·1 answer
  • An algorithmic function that takes an input message of arbitrary length and returns an output of fixed-length is called a(n) ___
    10·1 answer
  • How can I crack a computer password?
    10·1 answer
  • Answer for a, b, and c
    7·1 answer
  • Which of the following is considered a white collar crime?
    13·1 answer
  • How to build a 5*32 decoder by using 3*8 and 2*4 decoders? (digital design)
    15·1 answer
  • Int [] val = { 3, 10, 44 };
    13·1 answer
  • You are hired by a game design company and one of their most popular games is The Journey. The game has a ton of quests, and for
    12·2 answers
  • Which of these is a Microsoft certification for system engineers
    7·1 answer
  • Which type of input devices used in big hero 6 movie
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!