Skip to content

15lesson #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions 10lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# lottery game
import secrets
secureNumber = secrets.SystemRandom()
# build object
# print(secureNumber)

while True:
print('_________Welcome to 2D game with Python Programming_________')
press1 = int(input('______Press 1 for RULES OR 2 to start Game!____'))
if press1 == 1:
print(' >Your Age must be greater than or equal 17! ')
print(' >You need aleast 10000 Coin! ')
print(' >Your need to use aleast 1000 Coin to start game! ')
if press1 == 2:
print(' >You can start to play game Now! -----------')
print(' > Now, You need to fill some of your informations...')
print('Lets Start!')
clientName = input('Type your name : at least 3 words')
clientAge = int(input('Type your age : at least 17year!'))
print('_____you entered___', len(clientName))
print('_____you entered___', clientAge)
if len(clientName) < 3:
print('Your Name must be aleast 3Characters!')
exit()
if clientAge < 17:
print('Your Age must be aleast 17!')
exit()
while len(clientName) >= 3 and clientAge >= 17:
print('You can play game Now. ...')
print('Welcome', clientName ,'!. . ')
while True:
clientMoney = int(input('Now, Enter your coin! : aleast 10000 Coin'))
while clientMoney < 10000 or None:
print('Coin must be aleast 10000!', clientName, 'coin is', clientMoney )
clientMoney = int(input('Please valid coin!'))
if clientMoney < 10000:
continue
while clientMoney >= 10000:
if clientMoney >= 10000:
print('your money is ', clientMoney)
print('Hello', clientName, 'Thanks You! - - - -')
clientUseMoney = int(input('How many conin wanna use ? Enter. :aleast 1000 : '))
while clientUseMoney < 1000 or None:
print('Use Coin must be aleast 1000!', clientName, 'Used coin is : ', clientUseMoney )
clientUseMoney = int(input('Please valid Use coin!'))
if clientUseMoney < 1000:
continue
if clientUseMoney >= 1000:
print('You used ', clientUseMoney , 'coin for game!- - -')
luckyNum = int(input('Insert your lucky Number! Must be two Number!------ '))
while len(str(luckyNum)) < 2 or None:
print('Use two number!', clientName, 'inserted lucky number is', luckyNum )
luckyNum = int(input('Please valid Luck Number!'))
while len(str(luckyNum)) < 2 or len(str(luckyNum)) > 2:
continue
if len(str(luckyNum)) == 2:
sysNumber = secureNumber.randint(10,99)
countNum = 0
while countNum < 3:
print('Wait... What is Number Today is . . .')
countNum +=1
if luckyNum == sysNumber:
clientMoney = clientMoney + clientUseMoney
print('Today Number is : ', sysNumber)
print('Hey',clientName,'Congratulation. . .You Won!!!!----')
print('Hey',clientName,'You got',clientMoney)

playAgainNum = int(input('enter 1 to play again OR Enter 0 to QUIT****'))
while clientMoney > 0:
if playAgainNum == 1:
break
while playAgainNum == 0:
exit()
else:
clientMoney = clientMoney - clientUseMoney
print("Today number is :", sysNumber)
print("Your Lucky number is :", luckyNum)
print("Sorry..Good Luck again", clientName)
print('Hey',clientName,'Your Coin : ',clientMoney)
if clientMoney == 0 or clientMoney < 1000:
exit()








10 changes: 10 additions & 0 deletions 1112lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
yourInput = input('enter your number')
while True:
if yourInput.isdigit() and len(yourInput) <3:
print('your input must be atleast 3word')
break
elif yourInput.isdigit() and len(yourInput) > 3:
print('not greater than 3')
else:
print('ok')
break
80 changes: 80 additions & 0 deletions 13lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# for loop with example

# 1.while loop
# x = 0
# while x < 5:
# print(x)
# x += 1

# for loop with break
# i = 1
# while i < 6:
# print(i)
# if i == 3:
# break
# i += 1


# p = 10
# while p < 25:
# print(p)
# if p == 18:
# break
# p += 1

# for loop with continue
# 意味 => 止める現状の反復 / 次へ続く

# i = 0
# while i < 6:
# if i == 3:
# i += 1
# continue
# print(i)
# i += 1


# 2 range
# x = range(6)
# for n in x:
# print(n)

# range with for loop
# p = 0
# for p in range(5):
# print(p)

# Tuple
# tup=('h','e','l','l','o')
# for p in tup:
# print(p)
# Loop Tuple with list
# packing
# lootu = [(1,2),(3,4)]
# for p in lootu:
# print(p)
# unpacking
# for p,t in lootu:
# print(p,t)

# print(0%7)
# for p in range(5):
# t = p%3
# print(t)
# if t == 0:
# print('modulus')
# else:
# print('modulus not zero')

# Zero Division Error ___ Try Except Finally
# for p in range(5):
# print('loop in range 5, p : ', p)
# try:
# 10/(p-3)
# except ZeroDivisionError:
# print('divided by zero')
# finally:
# print('not divided by zero')



43 changes: 43 additions & 0 deletions 14lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# string with for loop
# words = 'pyaephyothant'
# for x in words:
# print(x, end='-')
# with index
# i = 0
# for x in words:
# print(i,x)
# i+=1
# enumerate
# for i,x in enumerate(words):
# print(i,x)

# row = int(input('write number between 1 and 5'))
# for p in range(row):
# for t in range(p):
# print('*',t,'t')
# print('-',p,'p')


# row = int(input('write number between 1 and 10'))
# for p in range(row):
# for t in range(p):
# print(t,end='')
# print('-')

# for p in range(1,row):
# # print(p,'p')
# for t in range(p):
# print(t,end='')
# print('-')

# x = range(3, 0, -2)
# print(x)
# for n in x:
# print(n)

putInNumber = int(input('insert value of a number between 1 and 5 = '))
for p in range(5,putInNumber):
for t in range(p,0,-1):
print('t',t)
print('-')

21 changes: 21 additions & 0 deletions 15lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# pyramic triangle
# forRow = int(input('Enter number to make pyramic'))
# spaceRow = forRow
# for i in range(1,forRow):
# for j in range(spaceRow):
# print(end=' ')
# spaceRow = spaceRow-1
# for k in range(1,i*2):
# print('*',end='')
# print('')

# reverse pyramic triangle
forRow = int(input('Enter number to make reverse pyramic'))
forStar = forRow
for i in range(1,forRow):
for j in range(i):
print(' ',end='')
for k in range((forStar*2),3,-1):
print('*',end='')
forStar = forStar-1
print(' ')
52 changes: 52 additions & 0 deletions 7lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# while loop

# i = 1
# while i < 10:
# print('looping number of i value is : {}'.format(i))
# i += 1

# while loop exercise
p = 0
t = 5

# while t > p :
# print('p is' , p, 't is' , t)
# t -= 1

# break and continue

# for pt in 'pathein':
# if pt == 'n':
# break
# print('without break')

# print('----------breaked--------------')


# for pp in 'yangon':
# if pp == 'n':
# continue
# print('without break',pp)
# print('---------continue-----')



# while and break programm
ls = [10,20,60,99]
compareNum = 99
found = False
index = 0
# print(len(ls))

while index < len(ls):
if ls[index] == compareNum:
found = True
break
index += 1

if not found:
# print(not found)
ls.append(compareNum)

# print(ls)

49 changes: 49 additions & 0 deletions 8lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Random
import random


# The random() method returns a random floating number between 0 and 1.
# print(random.random())

# for integers randint() randrange()
# print(random.randint(2,6))

# random.randrange(start, stop, step)
print(random.randrange(2,8,2))

# random.choice(sequence)
# random.sample(sequence, k) sequence Required. A sequence. Can be any sequence: list, set, range etc. && k Required. The size of the returned list
# fruits = ['Apple', 'Banana', 'Orange', 'Grapes', 'Strawberry']
# print(random.choice(fruits))
# print(random.sample(fruits,2))

# random.seed(a, version)
# *** Random.seed is not secure!!!!!!!!!!!!!!!!!!
# a Optional. The seed value needed to generate a random number.
# If it is an integer it is used directly, if not it has to be converted into an integer.
# Default value is None, and if None, the generator uses the current system time.

# version An integer specifying how to convert the a parameter into a integer.
# Default value is 2

# random.seed(42)
# print(random.random())

# shuffle
# Shuffle a list (reorganize the order of the list items):
# fruits = ['Apple', 'Banana', 'Orange', 'Grapes', 'Strawberry']
# print('Before Shuffle/ original fruits list', fruits)
# random.shuffle(fruits)
# print('Shuffled List', fruits)

# uniform random.uniform(a, b)
# a Required. A number specifying the lowest possible outcome
# b Required. A number specifying the highest possible outcome
# The uniform() method returns a random floating number between the two specified numbers (both included).

# print('uniform', random.uniform(5,10))
# random.triangular(low, high, mode)
# print(random.triangular(20, 60, 10))



38 changes: 38 additions & 0 deletions 9lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Secure random
import secrets

# secrets.SystemRandom

# randint & randint
# secureGenerator = secrets.SystemRandom()
# secureRandNumber = secureGenerator.randint(2,10)
# print('secured random numbers', secureRandNumber)

# secureGenerator = secrets.SystemRandom()
# secureRandNumberByRange = secureGenerator.randrange(2,11,4)
# ရွေးချယ်ခွင့် တိုးပွားမှုကို သတ်မှတ်သည့် ကိန်းပြည့်။ default 1
# print('secured random numbers ranges', secureRandNumberByRange)

# choice & sample
# fruits = ['Apple', 'Banana', 'Orange', 'Grapes', 'Strawberry']
# secureGenerator = secrets.SystemRandom()
# secureFruit = secureGenerator.choice(fruits)
# print('securedFruit', secureFruit)

# secureGenerator = secrets.SystemRandom()
# secureFruitSample = secureGenerator.sample(fruits,2)
# print('secureFruitSample', secureFruitSample)

# secret.token_byte
# print(secrets.token_bytes(4))
# print(secrets.token_bytes(2))
# secret.token_hex 2 => 4 , 4 => 8
# print(secrets.token_hex(3))

# Token URL safe
# print(secrets.token_urlsafe(2))

passwordResetLink = 'http://resetUrlLink/reset='
passwordResetLink += secrets.token_urlsafe()
print('url secretlinks', passwordResetLink)

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
> Learning Python Programming . . .

> Learning Python Programming Language
Loading