-
Notifications
You must be signed in to change notification settings - Fork 12
/
Python01_Introduction
85 lines (59 loc) · 1.38 KB
/
Python01_Introduction
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
## Python
## Introduction
## Say "Hello, World!" With Python
print("Hello, World!")
## Python If-Else
#!/bin/python3
import math
import os
import random
import re
import sys
if __name__ == '__main__':
n = int(input().strip())
if n%2 == 1:
print('Weird')
else:
if n >=2 and n <= 5:
print('Not Weird')
elif n >=6 and n <= 20:
print('Weird')
elif n > 20:
print('Not Weird')
## Arithmetic Operators
if __name__ == '__main__':
a = int(input())
b = int(input())
print(a+b)
print(a-b)
print(a*b)
## Python: Division
if __name__ == '__main__':
a = int(input())
b = int(input())
print(a//b)
print(a/b)
## Loops
if __name__ == '__main__':
n = int(input())
for i in range(n):
print(i**2)
## Write a function
def is_leap(year):
leap = False
# Write your logic here
if year%100==0 and year%400==0:
leap = True
elif year%4==0 and year%100!=0:
leap = True
return leap
# 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.
## Print Function
if __name__ == '__main__':
n = int(input())
for i in range(1,n+1):
print(i, end='')
## end ##