-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday2.py
More file actions
55 lines (37 loc) · 925 Bytes
/
day2.py
File metadata and controls
55 lines (37 loc) · 925 Bytes
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
#logical operators
1 == 1
#will evaluate as true because 1 equals 1
2 == 5
#will evaluate as false because 2 does not equal 5
2 != 4
#will evaluate as true because 2 does not equal 4
#AND - all expressions must be true to evaluate to true
print('and expressions')
a= 1==1 and 2 == 2
print(a)
b= 1==1 and 1 == 2
print(b)
c= 1==1 and 10!=3 and 4<2
print(c)
#OR - will evaluate to true if any one of the expressions is true
print('or expressions')
d= 1==2 or 2==2
print(d)
e= 1==2 or 2==1
print(e)
#NOT - will change boolean value of any expression to it's opposite (T->F and F->T)
print('not expressions')
f= not 1==1
print(f)
g= not 1==2
print(g)
##user input
#default class for input is <str>
name=input('What is your name: ')
print('Hello', name)
num=input('Enter a number: ')
#or num=int(input('Enter a number: '))
#number is still a <str> value
num=int(num)
ans=num*3
print('your number times 3 is', ans)