We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Introduction
- Python If-Else
- Discussions
Python If-Else
Python If-Else
Sort by
recency
|
4494 Discussions
|
Please Login in order to post a comment
Why is this failing on number 29
!/bin/python3
import math import os import random import re import sys
if name == 'main': n = int(input().strip())
if n in range(1, 101): if n % 2==0 and n in range(6, 21): print("Weird") elif n % 2==0 and n in range(2, 6) or n > 20: print("Not Weird") elif n % 2==1: print("Weird")
n = int(input()) student_marks = {} for _ in range(n): data = input().split() name = data[0] scores = list(map(float, data[1:])) student_marks[name] = scores query_name = input() average_marks = sum(student_marks[query_name]) / len(student_marks[query_name])
print(f"{average_marks:.2f}")
This fails on the numbers 18 and 20 in here, but runs correctly locally on python 3.12.7
For Python3 Platform
n = int(input().strip())
print("Not Weird" if n % 2 == 0 and (n in range(2,6) or n > 20) else "Weird")