-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforloops.py
139 lines (128 loc) · 3.1 KB
/
forloops.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#FOR LOOPS
# for ada in 'Python':
# print(ada)
# for ada in {1, 'a', 'b'}:
# print(ada)
# print('bye')
# print('22323')
# my_str = input('Enter Something: ')
# vowels = 'aeiou'
# for item in my_str:
# if item in vowels:
# print(item, end=' ')
# print('Hello Python!')
# x=101
# y = x // 2
# for n in [1, 2, 3, 4, 5, 6, 7]:
# nn=n ** 2
# if nn % 2 ==0:
# print(f'{nn} is even.')
# else:
# print(f'{nn} is odd.')
# #RANGES
# r = range(2,10,3)
# print(type(r))
# print(list(r))
#LOOPS AND RANGES
# s=0
# for n in range(101):
# s += n
# print(f'Sum:{s}')
# for _ in range(10):
# print('Do something',_)
# import random
# names= ['Diana', 'Pail', 'Ana', 'Dan', 'Victor', 'marry', 'Alexandra', 'Maria','Jeff', 'Bob', 'Bill', 'Angie']
# for _ in range(3):
# print(f'Choosing winner. Round {_}...')
# winner= random.choice(names)
# names.remove(winner)
# print(winner)
# print('############')
###########################################################
##For, countine and pass Statements
# for letter in 'Go Python goooo!':
# if letter == 'o':
# continue
# print(letter, end='')
#
# for n in range(10):
# if n % 2 ==0:
# print(f'Found an even number: {n}')
# continue
# print(f'Found an odd number: {n}')
# for n in range(10):
# if n % 2 ==0:
# pass
# print(f'Found an even number: {n}')
# print(f'Found an odd number: {n}')
# for number in range(10):
# print(number)
# if number == 5:
# break
# exit() #stop entire scrips
# print('Ouside For')
# for letter in 'Python':
# if letter == 'o':
# print('letter is p and break')
# break
# print(letter)
# for n in range(1,12):
# if n % 13 ==0:
# print('Breaking')
# else:
# print('There is no 13 ile bolunen')
# for l in 'abc':
# print(l)
# for n in range(3):
# if n==1:
# break
# print(n)
#While loops
# x=0
# while x<10:
# print(f'infineteloop {x}')
# x+=1
# else:
# print(f'Printing Fnisidadada')
#While And Continue
# x=12
# while x<100:
# x=x+1
# if x % 13 !=0: continue
# print(x)
# while True:
# guess = int(input('Enter Your lucky number: '))
# if guess==7:
# print(f'You win')
# break
# print(f'{guess} was not')
# a= int(input('Enter Number: '))
# while a >1:
# b= a//2
# while b>1:
# if a %b ==0:
# break
# b -=1
# else:
# print(f'{a} is prime')
# a -=1
##### THE WALRUS OPERATOR
# NAME := expression
# print(x := 2+3)
# print(f'x is {x}')
# value = input('Enter something: ')
# while value !='':
# print(f'You Entered: {value}')
# value = input('Enter something: ')
# while(value := input('Enter something: ')) !='':
# print(f'You entered {value}')
# data = input('Enter Your Name: ')
# if len(data) > 0:
# print(f'Your name has {len(data)} character')
# else:
# print('Your Name cant not empty')
#
# if len(data := input('Enter your name: ')) >0:
# print(f'Your name has {len(data)} character')
# else:
# print(f'Your name can not be emty')