diff --git a/10lesson.py b/10lesson.py new file mode 100644 index 0000000..beac9c3 --- /dev/null +++ b/10lesson.py @@ -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() + + + + + + + + \ No newline at end of file diff --git a/1112lesson.py b/1112lesson.py new file mode 100644 index 0000000..22e239c --- /dev/null +++ b/1112lesson.py @@ -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 \ No newline at end of file diff --git a/13lesson.py b/13lesson.py new file mode 100644 index 0000000..8bc3074 --- /dev/null +++ b/13lesson.py @@ -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') + + + diff --git a/14lesson.py b/14lesson.py new file mode 100644 index 0000000..b4fcc43 --- /dev/null +++ b/14lesson.py @@ -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('-') + diff --git a/15lesson.py b/15lesson.py new file mode 100644 index 0000000..5d7ef1a --- /dev/null +++ b/15lesson.py @@ -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(' ') \ No newline at end of file diff --git a/7lesson.py b/7lesson.py new file mode 100644 index 0000000..3351f3b --- /dev/null +++ b/7lesson.py @@ -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) + diff --git a/8lesson.py b/8lesson.py new file mode 100644 index 0000000..f297b65 --- /dev/null +++ b/8lesson.py @@ -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)) + + + diff --git a/9lesson.py b/9lesson.py new file mode 100644 index 0000000..a6e9912 --- /dev/null +++ b/9lesson.py @@ -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) + diff --git a/README.md b/README.md index efcda87..0ecaa70 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ +> Learning Python Programming . . . + > Learning Python Programming Language diff --git a/lesson3.py b/lesson3.py index 677acb7..5cfdc49 100644 --- a/lesson3.py +++ b/lesson3.py @@ -4,14 +4,14 @@ z = "green" x = y = z = 20 -print("x",x) -print("y",y) -print("z",z) +# print("x",x) +# print("y",y) +# print("z",z) x = 5 y = 15 -print("x",x) -print("y",y) +# print("x",x) +# print("y",y) # identifier @@ -37,4 +37,35 @@ # Tuple # dictionary +# arithmetic operators +x = 1.1 +y = 2.2 +# print(x+y) + +a = 5 +b = 6 +# print(a*b) + +c = 3.9 +d = 3.3 +# print(c/d) +# print(c%d) + +# complex (use j/J) real part + imginary part +a = complex(1,2) +# print(a) +# print(a.real) +# print(a.imag) + +# convert using float() int() and complex() +x = 100 +y = 2.8 +z = 1j + +# convert integer to float +print(float(x)) +# convert float to integer +print(int(y)) +# convert int to complex +print(complex(x)) \ No newline at end of file diff --git a/lesson4.py b/lesson4.py new file mode 100644 index 0000000..791fbda --- /dev/null +++ b/lesson4.py @@ -0,0 +1,37 @@ +# control structures +a = 400 +b = 300 +# if a < b : +# # print('a less than b') +# else : +# # print('b greater than a') + + +c = 500 +d = 500 +# if c < d: +# # print('c less than d') +# elif c > d: +# # print('c greater than d') +# else : +# # print('c and d value are equal') + +# largest Number +a = 100 +b = 200 +c = 300 +d = 400 + +if (a > b) and (a > c) and (a > d) : + largestNumber = a + print('Largest Number is : ', largestNumber) +elif (b > a ) and ( b > c) and (b > d) : + largestNumber = b + print('largest Number is : ', b) +elif (c > a) and (c > b) and (c > d): + largestNumber = c + print('largest Number is : ', largestNumber) +else : + largestNumber = d + print('largest Number is : ', largestNumber) + diff --git a/lesson5.py b/lesson5.py new file mode 100644 index 0000000..7f19ddb --- /dev/null +++ b/lesson5.py @@ -0,0 +1,37 @@ +# calculator program +# Lesson 5 + +print("Press + for Add") +print("Press - for Subtract") +print("Press * for Multiply") +print("Press / for Divide") + +userInput = input('please enter operator for Add or Subtract or Multiply or Divide') +# print(userInput) +print('you entered : ', userInput) + +firstNumber = int(input('Enter Your First Number')) +print('your first number is : ', firstNumber) + +secondNumber = int(input('Enter Your Second Number')) +print('your second number is : ', secondNumber) + +if userInput == '+' : + result = firstNumber + secondNumber + print('result is :', result) +elif userInput == '-' : + result = firstNumber * secondNumber + print('result is :', result) +elif userInput == '*' : + result = firstNumber * secondNumber + print('result is :', result) +elif userInput == '/' : + result = firstNumber / secondNumber + print('result is :', result) +else : + print('your input {} is invalid ! Please try again later!'.format(userInput) ) + exit() + + + +