Skip to content

Commit cd6f24a

Browse files
Merge pull request #8 from coderpyaephyothant/15lesson
15lesson
2 parents 7884f72 + 430f39d commit cd6f24a

File tree

12 files changed

+494
-5
lines changed

12 files changed

+494
-5
lines changed

10lesson.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# lottery game
2+
import secrets
3+
secureNumber = secrets.SystemRandom()
4+
# build object
5+
# print(secureNumber)
6+
7+
while True:
8+
print('_________Welcome to 2D game with Python Programming_________')
9+
press1 = int(input('______Press 1 for RULES OR 2 to start Game!____'))
10+
if press1 == 1:
11+
print(' >Your Age must be greater than or equal 17! ')
12+
print(' >You need aleast 10000 Coin! ')
13+
print(' >Your need to use aleast 1000 Coin to start game! ')
14+
if press1 == 2:
15+
print(' >You can start to play game Now! -----------')
16+
print(' > Now, You need to fill some of your informations...')
17+
print('Lets Start!')
18+
clientName = input('Type your name : at least 3 words')
19+
clientAge = int(input('Type your age : at least 17year!'))
20+
print('_____you entered___', len(clientName))
21+
print('_____you entered___', clientAge)
22+
if len(clientName) < 3:
23+
print('Your Name must be aleast 3Characters!')
24+
exit()
25+
if clientAge < 17:
26+
print('Your Age must be aleast 17!')
27+
exit()
28+
while len(clientName) >= 3 and clientAge >= 17:
29+
print('You can play game Now. ...')
30+
print('Welcome', clientName ,'!. . ')
31+
while True:
32+
clientMoney = int(input('Now, Enter your coin! : aleast 10000 Coin'))
33+
while clientMoney < 10000 or None:
34+
print('Coin must be aleast 10000!', clientName, 'coin is', clientMoney )
35+
clientMoney = int(input('Please valid coin!'))
36+
if clientMoney < 10000:
37+
continue
38+
while clientMoney >= 10000:
39+
if clientMoney >= 10000:
40+
print('your money is ', clientMoney)
41+
print('Hello', clientName, 'Thanks You! - - - -')
42+
clientUseMoney = int(input('How many conin wanna use ? Enter. :aleast 1000 : '))
43+
while clientUseMoney < 1000 or None:
44+
print('Use Coin must be aleast 1000!', clientName, 'Used coin is : ', clientUseMoney )
45+
clientUseMoney = int(input('Please valid Use coin!'))
46+
if clientUseMoney < 1000:
47+
continue
48+
if clientUseMoney >= 1000:
49+
print('You used ', clientUseMoney , 'coin for game!- - -')
50+
luckyNum = int(input('Insert your lucky Number! Must be two Number!------ '))
51+
while len(str(luckyNum)) < 2 or None:
52+
print('Use two number!', clientName, 'inserted lucky number is', luckyNum )
53+
luckyNum = int(input('Please valid Luck Number!'))
54+
while len(str(luckyNum)) < 2 or len(str(luckyNum)) > 2:
55+
continue
56+
if len(str(luckyNum)) == 2:
57+
sysNumber = secureNumber.randint(10,99)
58+
countNum = 0
59+
while countNum < 3:
60+
print('Wait... What is Number Today is . . .')
61+
countNum +=1
62+
if luckyNum == sysNumber:
63+
clientMoney = clientMoney + clientUseMoney
64+
print('Today Number is : ', sysNumber)
65+
print('Hey',clientName,'Congratulation. . .You Won!!!!----')
66+
print('Hey',clientName,'You got',clientMoney)
67+
68+
playAgainNum = int(input('enter 1 to play again OR Enter 0 to QUIT****'))
69+
while clientMoney > 0:
70+
if playAgainNum == 1:
71+
break
72+
while playAgainNum == 0:
73+
exit()
74+
else:
75+
clientMoney = clientMoney - clientUseMoney
76+
print("Today number is :", sysNumber)
77+
print("Your Lucky number is :", luckyNum)
78+
print("Sorry..Good Luck again", clientName)
79+
print('Hey',clientName,'Your Coin : ',clientMoney)
80+
if clientMoney == 0 or clientMoney < 1000:
81+
exit()
82+
83+
84+
85+
86+
87+
88+
89+

1112lesson.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
yourInput = input('enter your number')
2+
while True:
3+
if yourInput.isdigit() and len(yourInput) <3:
4+
print('your input must be atleast 3word')
5+
break
6+
elif yourInput.isdigit() and len(yourInput) > 3:
7+
print('not greater than 3')
8+
else:
9+
print('ok')
10+
break

13lesson.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# for loop with example
2+
3+
# 1.while loop
4+
# x = 0
5+
# while x < 5:
6+
# print(x)
7+
# x += 1
8+
9+
# for loop with break
10+
# i = 1
11+
# while i < 6:
12+
# print(i)
13+
# if i == 3:
14+
# break
15+
# i += 1
16+
17+
18+
# p = 10
19+
# while p < 25:
20+
# print(p)
21+
# if p == 18:
22+
# break
23+
# p += 1
24+
25+
# for loop with continue
26+
# 意味 => 止める現状の反復 / 次へ続く
27+
28+
# i = 0
29+
# while i < 6:
30+
# if i == 3:
31+
# i += 1
32+
# continue
33+
# print(i)
34+
# i += 1
35+
36+
37+
# 2 range
38+
# x = range(6)
39+
# for n in x:
40+
# print(n)
41+
42+
# range with for loop
43+
# p = 0
44+
# for p in range(5):
45+
# print(p)
46+
47+
# Tuple
48+
# tup=('h','e','l','l','o')
49+
# for p in tup:
50+
# print(p)
51+
# Loop Tuple with list
52+
# packing
53+
# lootu = [(1,2),(3,4)]
54+
# for p in lootu:
55+
# print(p)
56+
# unpacking
57+
# for p,t in lootu:
58+
# print(p,t)
59+
60+
# print(0%7)
61+
# for p in range(5):
62+
# t = p%3
63+
# print(t)
64+
# if t == 0:
65+
# print('modulus')
66+
# else:
67+
# print('modulus not zero')
68+
69+
# Zero Division Error ___ Try Except Finally
70+
# for p in range(5):
71+
# print('loop in range 5, p : ', p)
72+
# try:
73+
# 10/(p-3)
74+
# except ZeroDivisionError:
75+
# print('divided by zero')
76+
# finally:
77+
# print('not divided by zero')
78+
79+
80+

14lesson.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# string with for loop
2+
# words = 'pyaephyothant'
3+
# for x in words:
4+
# print(x, end='-')
5+
# with index
6+
# i = 0
7+
# for x in words:
8+
# print(i,x)
9+
# i+=1
10+
# enumerate
11+
# for i,x in enumerate(words):
12+
# print(i,x)
13+
14+
# row = int(input('write number between 1 and 5'))
15+
# for p in range(row):
16+
# for t in range(p):
17+
# print('*',t,'t')
18+
# print('-',p,'p')
19+
20+
21+
# row = int(input('write number between 1 and 10'))
22+
# for p in range(row):
23+
# for t in range(p):
24+
# print(t,end='')
25+
# print('-')
26+
27+
# for p in range(1,row):
28+
# # print(p,'p')
29+
# for t in range(p):
30+
# print(t,end='')
31+
# print('-')
32+
33+
# x = range(3, 0, -2)
34+
# print(x)
35+
# for n in x:
36+
# print(n)
37+
38+
putInNumber = int(input('insert value of a number between 1 and 5 = '))
39+
for p in range(5,putInNumber):
40+
for t in range(p,0,-1):
41+
print('t',t)
42+
print('-')
43+

15lesson.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# pyramic triangle
2+
# forRow = int(input('Enter number to make pyramic'))
3+
# spaceRow = forRow
4+
# for i in range(1,forRow):
5+
# for j in range(spaceRow):
6+
# print(end=' ')
7+
# spaceRow = spaceRow-1
8+
# for k in range(1,i*2):
9+
# print('*',end='')
10+
# print('')
11+
12+
# reverse pyramic triangle
13+
forRow = int(input('Enter number to make reverse pyramic'))
14+
forStar = forRow
15+
for i in range(1,forRow):
16+
for j in range(i):
17+
print(' ',end='')
18+
for k in range((forStar*2),3,-1):
19+
print('*',end='')
20+
forStar = forStar-1
21+
print(' ')

7lesson.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# while loop
2+
3+
# i = 1
4+
# while i < 10:
5+
# print('looping number of i value is : {}'.format(i))
6+
# i += 1
7+
8+
# while loop exercise
9+
p = 0
10+
t = 5
11+
12+
# while t > p :
13+
# print('p is' , p, 't is' , t)
14+
# t -= 1
15+
16+
# break and continue
17+
18+
# for pt in 'pathein':
19+
# if pt == 'n':
20+
# break
21+
# print('without break')
22+
23+
# print('----------breaked--------------')
24+
25+
26+
# for pp in 'yangon':
27+
# if pp == 'n':
28+
# continue
29+
# print('without break',pp)
30+
# print('---------continue-----')
31+
32+
33+
34+
# while and break programm
35+
ls = [10,20,60,99]
36+
compareNum = 99
37+
found = False
38+
index = 0
39+
# print(len(ls))
40+
41+
while index < len(ls):
42+
if ls[index] == compareNum:
43+
found = True
44+
break
45+
index += 1
46+
47+
if not found:
48+
# print(not found)
49+
ls.append(compareNum)
50+
51+
# print(ls)
52+

8lesson.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Random
2+
import random
3+
4+
5+
# The random() method returns a random floating number between 0 and 1.
6+
# print(random.random())
7+
8+
# for integers randint() randrange()
9+
# print(random.randint(2,6))
10+
11+
# random.randrange(start, stop, step)
12+
print(random.randrange(2,8,2))
13+
14+
# random.choice(sequence)
15+
# random.sample(sequence, k) sequence Required. A sequence. Can be any sequence: list, set, range etc. && k Required. The size of the returned list
16+
# fruits = ['Apple', 'Banana', 'Orange', 'Grapes', 'Strawberry']
17+
# print(random.choice(fruits))
18+
# print(random.sample(fruits,2))
19+
20+
# random.seed(a, version)
21+
# *** Random.seed is not secure!!!!!!!!!!!!!!!!!!
22+
# a Optional. The seed value needed to generate a random number.
23+
# If it is an integer it is used directly, if not it has to be converted into an integer.
24+
# Default value is None, and if None, the generator uses the current system time.
25+
26+
# version An integer specifying how to convert the a parameter into a integer.
27+
# Default value is 2
28+
29+
# random.seed(42)
30+
# print(random.random())
31+
32+
# shuffle
33+
# Shuffle a list (reorganize the order of the list items):
34+
# fruits = ['Apple', 'Banana', 'Orange', 'Grapes', 'Strawberry']
35+
# print('Before Shuffle/ original fruits list', fruits)
36+
# random.shuffle(fruits)
37+
# print('Shuffled List', fruits)
38+
39+
# uniform random.uniform(a, b)
40+
# a Required. A number specifying the lowest possible outcome
41+
# b Required. A number specifying the highest possible outcome
42+
# The uniform() method returns a random floating number between the two specified numbers (both included).
43+
44+
# print('uniform', random.uniform(5,10))
45+
# random.triangular(low, high, mode)
46+
# print(random.triangular(20, 60, 10))
47+
48+
49+

9lesson.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Secure random
2+
import secrets
3+
4+
# secrets.SystemRandom
5+
6+
# randint & randint
7+
# secureGenerator = secrets.SystemRandom()
8+
# secureRandNumber = secureGenerator.randint(2,10)
9+
# print('secured random numbers', secureRandNumber)
10+
11+
# secureGenerator = secrets.SystemRandom()
12+
# secureRandNumberByRange = secureGenerator.randrange(2,11,4)
13+
# ရွေးချယ်ခွင့် တိုးပွားမှုကို သတ်မှတ်သည့် ကိန်းပြည့်။ default 1
14+
# print('secured random numbers ranges', secureRandNumberByRange)
15+
16+
# choice & sample
17+
# fruits = ['Apple', 'Banana', 'Orange', 'Grapes', 'Strawberry']
18+
# secureGenerator = secrets.SystemRandom()
19+
# secureFruit = secureGenerator.choice(fruits)
20+
# print('securedFruit', secureFruit)
21+
22+
# secureGenerator = secrets.SystemRandom()
23+
# secureFruitSample = secureGenerator.sample(fruits,2)
24+
# print('secureFruitSample', secureFruitSample)
25+
26+
# secret.token_byte
27+
# print(secrets.token_bytes(4))
28+
# print(secrets.token_bytes(2))
29+
# secret.token_hex 2 => 4 , 4 => 8
30+
# print(secrets.token_hex(3))
31+
32+
# Token URL safe
33+
# print(secrets.token_urlsafe(2))
34+
35+
passwordResetLink = 'http://resetUrlLink/reset='
36+
passwordResetLink += secrets.token_urlsafe()
37+
print('url secretlinks', passwordResetLink)
38+

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
> Learning Python Programming . . .
2+
13
> Learning Python Programming Language

0 commit comments

Comments
 (0)