Instagram
youtube
Facebook
Twitter

Python picnic and temperature programme Codechef solution

Problem

The chef is planning a family picnic. He will go to the picnic only if the temperature on that day is strictly greater than 24 degrees.

Given that the temperature on a given day is X degrees, find out whether he will go to the picnic on that day.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.

  • Each test case consists of a single integer, X, representing the temperature on a given day.

Output Format

For each test case, output on a new line YES if Chef will go to the picnic and NO otherwise.

You may print each character in uppercase or lowercase. For example, NO, NO, NO, and nO are all considered the same.

Constraints

  • 1<=T<=100

  • 1<=X<=100

Sample Input:

4 
12 
24 
25 
60

Sample Output:

NO 
NO 
YES 
YES

Explanation:

Test case 1: The temperature on the day is 12, which is not >24. Thus, Chef will not go to the picnic.

Test case 2: The temperature on the day is 24, which is not >24. Thus, Chef will not go to the picnic.

Test case 3: The temperature on the day is 25, which is >24. Thus, Chef will go to the picnic.

Test case 4: The temperature on the day is 60, which is >24. Thus, Chef will go to the picnic.

Solution:

t=int(input(“Enter number of terms: “))
for i in range(t):
    x=int(input(“Enter temperature of a day: “))
    if(x>24):
        print("YES")
    else:
        print("NO")

Steps to solve this problem:

  • Ask the user to enter the number of terms to execute the loop and store it in

  • In loop, ask the user to enter the temperature of a day.

  • Check If the temperature is greater than 24, print YES; otherwise, print NO.