forked from shubhansu-kr/INT213-Python-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_Conditionals.py
63 lines (45 loc) · 1.21 KB
/
04_Conditionals.py
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
# Conditonal Statements
# Syntax
# if (condition):
# (Block statement)
if 1:
print('It\'s True')
else:
print('It\'s False')
if 0:
print('It\'s True')
else:
print('It\'s False')
# Blocks in python is created/differentiated using indentation
# indentation: Leaving Tab space
age = int(input('Enter your age '))
if (age >= 18):
print('You can vote in the election')
else:
print('You cannot vote in the election')
# Conditional on list
courses = ['Python', 'DBMS', 'DSA']
print(courses)
course_name = input('Enter Your course name ')
# string cannot be compared to list, so falsy value
if (course_name == courses):
print(course_name)
# in is used to loop in courses : IF course name is in list courses print name
if (course_name in courses):
print(course_name)
name = 'Python'
user_name = input('Enter Name ')
if (user_name == name):
print ('Saanp paal rha tha')
else:
print ('Hello')
# Nested if & laddered if
course_code = input('Enter your course code(Uppercase) ')
if (course_code == 'INT213'):
print('Python')
elif (course_code == 'INT306'):
print('Database')
elif (course_code == 'CSE205'):
print('DSA')
else:
print('You are not learning')