You are given an integer , you have to convert it into a string.Please complete the partially completed code in the editor. If your code successfully converts into a string the code will print "Good job". Otherwise it will print "Wrong answer". can range between to inclusive.Sample Input 0100Sample Output 0Good job
Question
You are given an integer , you have to convert it into a string.Please complete the partially completed code in the editor. If your code successfully converts into a string the code will print "Good job". Otherwise it will print "Wrong answer". can range between to inclusive.Sample Input 0100Sample Output 0Good job
Solution
Here is the solution:
n = int(input().strip())
try:
s = str(n)
print("Good job")
except:
print("Wrong answer")
This code works as follows:
- It takes an integer input from the user and stores it in the variable
n. - It then tries to convert the integer
ninto a stringsusing thestr()function. - If the conversion is successful, it prints "Good job".
- If an error occurs during the conversion (which should not happen with valid input), it prints "Wrong answer".
Similar Questions
Input FormatEvery line of input will contain a String followed by an integer.Each String will have a maximum of alphabetic characters, and each integer will be in the inclusive range from to .Output FormatIn each line of output there should be two columns:The first column contains the String and is left justified using exactly characters.The second column contains the integer, expressed in exactly digits; if the original input has less than three digits, you must pad your output's leading digits with zeroes.Sample Inputjava 100cpp 65python 50Sample Output================================java 100 cpp 065 python 050 ================================ExplanationEach String is left-justified with trailing whitespace through the first characters. The leading digit of the integer is the character, and each integer that was less than digits now has leading zeroes.
the above code is not working for the input s = "111" and t = "010". It is giving NO instead of YES
Write a program that takes a number 𝑁N as the input, and prints it to the output.Input FormatThe only line of input contains a single integer.Output FormatOutput the answer in a single line.Constraints0≤𝑁≤1050≤N≤10 5 Sample 1:InputOutput123123
Select the correct answerWhat is the output of the following code snippet?for (int i = 0; i < 5; i++) { System.out.print(i + " ");}Options0 1 2 3 40 1 2 3Compilation error1 2 3 4 5
Select the correct answerWhat is the output of the following program?public class Score{ public static void main(String[] args) { System.out.println((125/50.0)*Integer.parseInt("10") + 70); }}Options95.080Compilation errorRuntime error
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.