-
Notifications
You must be signed in to change notification settings - Fork 0
/
ifstatement.py
109 lines (86 loc) · 2.06 KB
/
ifstatement.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# x = int(input("Please enter an integer:"))
# if x < 0:
# x = 0
# print('Negative changed to zero')
# elif x == 0:
# print('zero')
# elif x == 1:
# print('Single')
# else:
# print('More')
# int - integer(Number)
# str -string(character)
# boolean - True , False
# float - 0.02, 0.5, 0.1
# x = int(input("Please enter an integer:"))
# if x < 5:
# print('x is smaller than 5')
# elif x > 10:
# print('x is bigger than 10')
# elif x == 7:
# print('x is equal to 7')
# elif x > 5 and x < 10:
# print('x is between 5 & 10')
# else:
# print('x is undefined')
# x = int(input("Please enter your age: "))
# if x > 0 and x <=18:
# print('Go to school')
# elif x >=19 and x <= 50:
# print('Go to beach')
# elif x >= 51 and x <= 75:
# print('Go to monastary')
# else:
# print('go to somewhere that you like')
#print('I told that'" I don't like it")
#measure some strings:
# words = ['cat','window','defenestrate']
# for w in words:
# print(w, len(w))
# fruits = ['apple','banana','cucumber','pineapple','orange']
# for f in fruits:
# print(f, len(f))
# for i in range(5):
# print(i)
# for x in range(0,100):
# print(x)
# a = ['Mary', 'had', 'a', 'little', 'lamb']
# for i in range(len(a)):
# print(i, a[i])
# #output
# 0 Mary
# 1 had
# 2 a
# 3 little
# 4 lamb
# sum(range(4))
# 6
# list(range(4))
# [0, 1, 2, 3]
# fruit = ['apple', 'banana', 'cucumber', 'pineapple', 'orange']
# fruit.append('grape')
# fruit
# ['apple', 'banana', 'cucumber', 'pineapple', 'orange', 'grape']
# fruit.remove('grape')
# fruit
# ['apple', 'banana', 'cucumber', 'pineapple', 'orange']
# fruit = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']
# fruit.count('apple')
# 2
# fruit.count('tangerine')
# 0
# fruit.index('banana')
# 3
# fruit.index('banana',4)
# 6
# fruit.reverse()
# fruit
# ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange']
# fruit.append('grape')
# fruit
# ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange', 'grape']
# fruit.sort()
# fruit
# ['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear']
# fruit.pop()
# 'pear'