Task 1:

Given an integer, , perform the following conditional actions:

If is odd, print Weird If is even and in the inclusive range of to , print Not Weird If is even and in the inclusive range of to , print Weird If is even and greater than , print Not Weird Input Format

A single line containing a positive integer, .

Constraints: 1<=n<=100

Output Format

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

Sample Input 0

3 Sample Output 0

Weird Sample Input 1

24 Sample Output 1

Not Weird Explanation

Sample Case 0:
is odd and odd numbers are weird, so we print Weird.

Sample Case 1:
n>20 and n is even, so it isn't weird. Thus, we print Not Weird.

Answer:


In [1]:
if __name__ == '__main__':
    n = int(input())
    if 1 <= n <= 100:
        if n%2 ==0:
            if n > 20 or 2<=n<=5:
                print ("Not Weird")
            else:
                print ("Weird")
        else:
            print ("Weird")


42
Not Weird

Task 2:

Read two integers from STDIN and print three lines where:

The first line contains the sum of the two numbers. The second line contains the difference of the two numbers (first - second). The third line contains the product of the two numbers. Input Format

The first line contains the first integer, . The second line contains the second integer, .

Constraints

1<=a<=10e10 and 1<=b<=10e10

Output Format

Print the three lines as explained above.

Sample Input

3 2 Sample Output

5 1 6

Answer:


In [2]:
if __name__ == '__main__':
    a = int(input())
    b = int(input())
    if 1<=a<=10e10 and 1<=b<=10e10:
        print (a+b)
        print (a-b)
        print (a*b)


5
7
12
-2
35

Task 3:

Read two integers and print two lines. The first line should contain integer division, // . The second line should contain float division, / .

You don't need to perform any rounding or formatting operations.

Input Format The first line contains the first integer, . The second line contains the second integer, .

Output Format Print the two lines as described above.

Sample Input

4 3 sample Output

1 1.3333333333333333

Answer:


In [3]:
if __name__ == '__main__':
    a = int(input())
    b = int(input())
    print (int(a//b))
    print (float(a/b))


8
9
0
0.8888888888888888

Task 4:

Read an integer . For all non-negative integers , print . See the sample for details.

Input Format

The first and only line contains the integer, .

Constraints

1<=n<=20

Output Format

Print lines, one corresponding to each .

Sample Input

5 Sample Output

0 1 4 9 16

Answer:


In [4]:
if __name__ == '__main__':
    n = int(input())
    if 1<=n<=20:
        for i in range(0,n):
            print (i*i)


19
0
1
4
9
16
25
36
49
64
81
100
121
144
169
196
225
256
289
324

Task 5:

We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary day and we add it to the shortest month of the year, February. In the Gregorian calendar three criteria must be taken into account to identify leap years:

The year can be evenly divided by 4, is a leap year, unless: The year can be evenly divided by 100, it is NOT a leap year, unless: The year is also evenly divisible by 400. Then it is a leap year.

This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.Source

Task You are given the year, and you have to write a function to check if the year is leap or not.

Note that you have to complete the function and remaining code is given as template.

Input Format

Read y, the year that needs to be checked.

Constraints

1900 <= y <= 10e5

Output Format

Output is taken care of by the template. Your function must return a boolean value (True/False)

Sample Input

1990
Sample Output

False
Explanation

1990 is not a multiple of 4 hence it's not a leap year.

Answer:


In [5]:
def is_leap(year):
    if 1900<= year <= 10e5:
        if year%4==0:
            if year%100==0 and year%400==0:
                leap = True
            else:
                if year%100==0:
                    leap = False
                else:
                    leap = True
        else:
            leap = False    
        return bool(leap)

In [6]:
year = int(input())
print(is_leap(year))


1970
False

Task 6:

Read an integer N.

Without using any string methods, try to print the following:

123...N

Note that "" represents the values in between.

Input Format The first line contains an integer N.

Output Format Output the answer as explained in the task.

Sample Input

3 Sample Output

123

Answer:


In [7]:
if __name__ == '__main__':
    n = int(input())
    for i in range(1, n+1):
        print(i, end='')


5
12345

In [ ]: