Knowee
Questions
Features
Study Tools

TaskGiven an integer, , perform the following conditional actions:If is odd, print WeirdIf is even and in the inclusive range of to , print Not WeirdIf is even and in the inclusive range of to , print WeirdIf is even and greater than , print Not WeirdInput FormatA single line containing a positive integer, .ConstraintsOutput FormatPrint Weird if the number is weird. Otherwise, print Not Weird.Sample Input 03Sample Output 0WeirdExplanation 0 is odd and odd numbers are weird, so print Weird.Sample Input 124Sample Output 1Not WeirdExplanation 1 and is even, so it is not weird.

Question

TaskGiven an integer, , perform the following conditional actions:If is odd, print WeirdIf is even and in the inclusive range of to , print Not WeirdIf is even and in the inclusive range of to , print WeirdIf is even and greater than , print Not WeirdInput FormatA single line containing a positive integer, .ConstraintsOutput FormatPrint Weird if the number is weird. Otherwise, print Not Weird.Sample Input 03Sample Output 0WeirdExplanation 0 is odd and odd numbers are weird, so print Weird.Sample Input 124Sample Output 1Not WeirdExplanation 1 and is even, so it is not weird.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

To solve this task, we need to check the given integer, n, for certain conditions and print the corresponding output.

  1. Read the input integer, n.
  2. Check if n is odd by using the modulo operator (%). If n % 2 is not equal to 0, then n is odd.
  3. If n is odd, print "Weird".
  4. If n is even, check if it falls within the range of 2 to 5 (inclusive). If n is greater than or equal to 2 and less than or equal to 5, it is within this range.
  5. If n is even and falls within the range of 2 to 5, print "Not Weird".
  6. If n is even, check if it falls within the range of 6 to 20 (inclusive). If n is greater than or equal to 6 and less than or equal to 20, it is within this range.
  7. If n is even and falls within the range of 6 to 20, print "Weird".
  8. If n is even and greater than 20, print "Not Weird".

Here is the code in Python:

n = int(input())

if n % 2 != 0:
    print("Weird")
elif n >= 2 and n <= 5:
    print("Not Weird")
elif n >= 6 and n <= 20:
    print("Weird")
else:
    print("Not Weird")

For the given sample input of 0, the output will be "Weird" because 0 is odd.

For the given sample input of 124, the output will be "Not Weird" because 124 is even and greater than 20.

This problem has been solved

Similar Questions

Given an integer, , perform the following conditional actions:If is odd, print WeirdIf is even and in the inclusive range of to , print Not WeirdIf is even and in the inclusive range of to , print WeirdIf is even and greater than , print Not WeirdInput FormatA single line containing a positive integer, .ConstraintsOutput FormatPrint Weird if the number is weird. Otherwise, print Not Weird.

TaskGiven a positive integer denoting , do the following:If , print the lowercase English word corresponding to the number (e.g., one for , two for , etc.).If , print Greater than 9.Input FormatThe first line contains a single integer, .ConstraintsOutput FormatIf , then print the lowercase English word corresponding to the number (e.g., one for , two for , etc.); otherwise, print Greater than 9 instead.Sample Input5Sample OutputfiveSample Input #018Sample Output #01eightSample Input #0244Sample Output #02Greater than 9

ingle File Programming QuestionProblem StatementAmil, a curious coder, has a distinctive approach to handling numerical input. Write a program to get an integer from the user. If the number is even, the system employs a goto statement to a label indicating an affirmative response. Otherwise, another goto statement conveys a negative response.Input format :The input consists of a single integer n.Output format :The output displays one of the following:If n is an even number, it displays "You entered an even number."If n is an odd number, it displays "You entered an odd number."Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:1 ≤ n ≤ 100Sample test cases :Input 1 :1Output 1 :You entered an odd number.Input 2 :100Output 2 :You entered an even number.Input 3 :67Output 3 :You entered an odd number.Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.

Given an integer input , whether the given input is "Positive" or "Negative" or "Zero" and print the corresponding messageInput Format:Enter an integer as a input  Output Format: Print the output as "Negative" or "Positive" or "Zero"Constraints:1 <= INPUT <= 10^15Sample Input 1:-98Sample Output 1:NEGATIVESample Input 2:0Sample Output 2:ZERO

Given an integer value, if it is divisible by 3 print “HI”, if it is divisible by 5 print “HELLO”. If it is divisible by both print “HIHELLO”, else  print "NONE"Input Format:Enter an integer as a inputOutput Format:Follow the format as sample output - "HI"or "HELLO" or "HIHELLO" or "NONE"Constraints:1 <= INPUT <= 10^15Sample Input 1:55Sample Output 1:HELLOSample Input 2:12Sample Output 2:HI

1/3

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.