Computer Science, asked by marvelTae, 2 months ago


Given an integer, n perform the following conditional actions:
• If n is odd, print Weird
. If n is even and in the inclusive range of 2 to 5 print Not Weird
if n is even and in the inclusive range of 6 to 20 print Weird
if n is even and greater than 20 print Not Weird

Answers

Answered by shrutivrm19
32

Answer:

n=int(input())

if(n%2!=0):

print("Weird")

else:

if( n>=2 and n<=5):

print("Not Weird")

elif(n>=6 and n<=20):

print("Weird")

else:

print("Not Weird")

Answered by aryansuts01
2

Answer:

Concept:

Conditionals (also known as conditional statements, conditional expressions, and conditional constructions) are programming language commands that are used to handle decisions in computer science. If a programmer-defined boolean condition evaluates to true or false, conditionals perform various computations or actions. The decision is always made in terms of control flow by selecting adjusting the control flow based on some situation (apart from the case of branch predication). Although dynamic dispatch is not considered a conditional construct, it is another means to choose amongst options at runtime.

Given:

n performs the conditional actions below given an integer:

If n is odd, print Weird

If n is even and in the inclusive range of 2 to 5 print Not Weird

if n is an even number in the range of 6 to 20, print Weird

Print Not Weird if n is even and greater than 20.

Find:

write a program by using given statements

Answer:

# Python If-Else

# Task

# Perform the conditional operations listed below given an integer, n:

# If n is odd, print Weird

# If n is even and in the inclusive range of 2 to 5, print Not Weird

# Print Weird if n is even and within the range of 6 to 20.

# If n is even and larger than 20, print Not Weird.

# Input Format

# n is a positive integer on a single line.

# Constraints

# 1 <= n <= 100

# Output Format

# Print Weird if the number is weird; otherwise, print Not Weird.

n = int(input())

if n % 2:

   print("Weird")

   elif 2 &lt; = n &lt; = 5:

       print("Not Weird")

       elif 6 &lt; = n &lt; = 20:

           print("Weird")

           else:

               print("Not Weird")

#SPJ3

Similar questions