Knowee
Questions
Features
Study Tools

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.

Question

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.

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

Solution

Sure, here is a Python solution for the problem:

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

This script first checks if the number is odd (n % 2 != 0). If it is, it prints "Weird". If it's not odd (i.e., it's even), it checks if it's in the range 2-5 inclusive. If it is, it prints "Not Weird". If it's not in that range, it checks if it's in the range 6-20 inclusive. If it is, it prints "Weird". Finally, if it's not in that range either, it checks if it's greater than 20. If it is, it prints "Not Weird".

This problem has been solved

Similar Questions

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.

What will be the output of the following code?x = -10if x > 0:    if x % 2 == 0:        print("Positive even")    else:        print("Positive odd")else:    if x % 2 == 0:        print("Negative even")    else:        print("Negative odd")Answer areaPositive evenPositive oddNegative evenNegative odd

Mandy is a software engineer working on a program to analyze two integers based on specific conditions using a logical operator. She needs to determine if both integers are odd or if at least one of them is divisible by 7.Depending on the result, she wants to print different messages. If the condition is met, the program should identify and print the number that is first divisible by 7 or indicate that both numbers are odd.If the condition is not met, the program should print a message indicating the condition was not met along with the input numbers.Input format :The first line of input consists of an integer representing the first input number.The second line consists of an integer representing the second input number.

Single 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.

Write a program to print only the even numbers till given NInput FormatA single integer 'N'Output FormatDisplay all the even numbers between 0 and NSample Input10Sample Output0 2 4 6 8 10

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.