From 427311b2a54a9371c1c6b11de5f627c03c70b05c Mon Sep 17 00:00:00 2001 From: omiplekevin Date: Wed, 10 Oct 2018 14:20:20 +0800 Subject: [PATCH 1/9] update exer_001.py - added solution for exercise file --- exer_001.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/exer_001.py b/exer_001.py index 0a225af..51cfbe4 100644 --- a/exer_001.py +++ b/exer_001.py @@ -12,8 +12,18 @@ """ # your name and email address here -__author__ = 'xXLXx ' +__author__ = 'xXLXx ' if __name__ == '__main__': - # your code here \ No newline at end of file + x = input() + if x in range(60, 75): + print "Derp!" + elif x in range(75, 85): + print "Good" + elif x in range(85, 95): + print "Very Good" + elif x in range(95, 101): + print "Level Asian!" + else: + print "Invalid Value" \ No newline at end of file From 55ca081ed4ed006655fdb9e6c59c17a064a6e6d5 Mon Sep 17 00:00:00 2001 From: lesteveinix Date: Wed, 10 Oct 2018 18:56:50 +0800 Subject: [PATCH 2/9] added my solution --- exer_001.py | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-) diff --git a/exer_001.py b/exer_001.py index 0a225af..02f49f9 100644 --- a/exer_001.py +++ b/exer_001.py @@ -12,8 +12,125 @@ """ # your name and email address here -__author__ = 'xXLXx ' +__author__ = 'lesteveinix ' if __name__ == '__main__': - # your code here \ No newline at end of file + # your code here + while 1: + try: + x = int(input('Enter a number from 60 to 100: ')) + + if x in range(60, 75): + print(''' + ,---, + ,`--.' | + ,---, | : : + .' .' `\ ,-.----. ' ' ; + ,---.' \ __ ,-.\ / \ | | | + | | .`\ | ,' ,'/ /|| : |' : ; + : : | ' | ,---. ' | |' || | .\ :| | ' + | ' ' ; : / \ | | ,'. : |: |' : | + ' | ; . | / / |' : / | | \ :; | ; + | | : | '. ' / || | ' | : . |`---'. | + ' : | / ; ' ; /|; : | : |`-' `--..`; + | | '` ,/ ' | / || , ; : : : .--,_ + ; : .' | : | ---' | | : | |`. + | ,.' \ \ / `---'.| `-- -`, ; + '---' `----' `---` '---`" + ''') + elif x in range(75, 85): + print(''' + + + ,----.. + / / \ ,---, + | : : ,---. ,---. ,---.'| + . | ;. / ' ,'\ ' ,'\ | | : + . ; /--` / / | / / | | | | + ; | ; __ . ; ,. :. ; ,. : ,--.__| | + | : |.' .'' | |: :' | |: : / ,' | + . | '_.' :' | .; :' | .; :. ' / | + ' ; : \ || : || : |' ; |: | + ' | '/ .' \ \ / \ \ / | | '/ ' + | : / `----' `----' | : :| + \ \ .' \ \ / + `---` `----' + + ''') + elif x in range(85, 95): + print(''' + ,---, + ,`--.' | + ,----.. | : : + ,---. / / \ ,---,' ' ; + /__./| __ ,-. | : : ,---. ,---. ,---.'|| | | + ,---.; ; | ,' ,'/ /| . | ;. / ' ,'\ ' ,'\ | | :' : ; + /___/ \ | | ,---. ' | |' | .--, . ; /--` / / | / / | | | || | ' + \ ; \ ' | / \ | | ,' /_ ./| ; | ; __ . ; ,. :. ; ,. : ,--.__| |' : | + \ \ \: | / / |' : /, ' , ' : | : |.' .'' | |: :' | |: : / ,' |; | ; + ; \ ' .. ' / || | '/___/ \: | . | '_.' :' | .; :' | .; :. ' / |`---'. | + \ \ '' ; /|; : | . \ ' | ' ; : \ || : || : |' ; |: | `--..`; + \ ` ;' | / || , ; \ ; : ' | '/ .' \ \ / \ \ / | | '/ '.--,_ + : \ || : | ---' \ \ ; | : / `----' `----' | : :|| |`. + '---" \ \ / : \ \ \ \ .' \ \ / `-- -`, ; + `----' \ ' ; `---` `----' '---`" + `--` + ''') + elif x in range(95, 101): + print(''' + ,--, ,---, + ,---.'| ,`--.' | + | | : ,--, ,---, | : : + : : | ,--.'| ' .' \ ,--, ' ' ; + | ' : | | : / ; '. ,--.'| ,---, | | | + ; ; ' .---. : : ' : : \ .--.--. | |, ,-+-. / |' : ; + ' | |__ ,---. /. ./| ,---. | ' | : | /\ \ / / ' `--'_ ,--.--. ,--.'|' || | ' + | | :.'| / \ .-' . ' | / \ ' | | | : ' ;. :| : /`./ ,' ,'| / \ | | ,"' |' : | + ' : ;/ / |/___/ \: |/ / || | : | | ;/ \ \ : ;_ ' | | .--. .-. | | | / | |; | ; + | | ./. ' / |. \ ' . ' / |' : |__ ' : | \ \ ,'\ \ `. | | : \__\/: . . | | | | |`---'. | + ; : ; ' ; /| \ \ ' ; /|| | '.'| | | ' '--' `----. \' : |__ ," .--.; | | | | |/ `--..`; + | ,/ ' | / | \ \ ' | / |; : ; | : : / /`--' /| | '.'|/ / ,. | | | |--' .--,_ + '---' | : | \ \ | : || , / | | ,' '--'. / ; : ; : .' \| |/ | |`. + \ \ / '---" \ \ / ---`-' `--'' `--'---' | , /| , .-./'---' `-- -`, ; + `----' `----' ---`-' `--`---' '---`" + + ''') + else: + print(''' + ,---, + ,`--.' | + ,---, ,--, ,---, ___ | : : + ,`--.' | ,--.'| ,--, ,---, ,`--.' | ,-.----. ,--.'|_ ' ' ; + | : : ,---, | | : ,--.'| ,---.'| | : : ,---, \ / \ ,--, | | :,' | | | + : | ' ,-+-. / | .---. : : ' | |, | | : : | ' ,-+-. / || : | ,'_ /| : : ' : ' : ; + | : | ,--.'|' | /. ./| ,--.--. | ' | `--'_ | | | | : | ,--.'|' || | .\ : .--. | | :.;__,' / | | ' + ' ' ;| | ,"' | .-' . ' | / \ ' | | ,' ,'| ,--.__| | ' ' ;| | ,"' |. : |: |,'_ /| : . || | | ' : | + | | || | / | |/___/ \: | .--. .-. || | : ' | | / ,' | | | || | / | || | \ :| ' | | . .:__,'| : ; | ; + ' : ;| | | | |. \ ' . \__\/: . .' : |__ | | : . ' / | ' : ;| | | | || : . || | ' | | | ' : |__ `---'. | + | | '| | | |/ \ \ ' ," .--.; || | '.'|' : |__ ' ; |: | | | '| | | |/ : |`-': | : ; ; | | | '.'| `--..`; + ' : || | |--' \ \ / / ,. |; : ;| | '.'|| | '/ ' ' : || | |--' : : : ' : `--' \ ; : ;.--,_ + ; |.' | |/ \ \ |; : .' \ , / ; : ;| : :| ; |.' | |/ | | : : , .-./ | , / | |`. + '---' '---' '---" | , .-./---`-' | , / \ \ / '---' '---' `---'.| `--`----' ---`-' `-- -`, ; + `--`---' ---`-' `----' `---` '---`" + + ''') + except: + print(''' + ,---, + ,`--.' | + ,---, ,--, ,---, ___ | : : + ,`--.' | ,--.'| ,--, ,---, ,`--.' | ,-.----. ,--.'|_ ' ' ; + | : : ,---, | | : ,--.'| ,---.'| | : : ,---, \ / \ ,--, | | :,' | | | + : | ' ,-+-. / | .---. : : ' | |, | | : : | ' ,-+-. / || : | ,'_ /| : : ' : ' : ; + | : | ,--.'|' | /. ./| ,--.--. | ' | `--'_ | | | | : | ,--.'|' || | .\ : .--. | | :.;__,' / | | ' + ' ' ;| | ,"' | .-' . ' | / \ ' | | ,' ,'| ,--.__| | ' ' ;| | ,"' |. : |: |,'_ /| : . || | | ' : | + | | || | / | |/___/ \: | .--. .-. || | : ' | | / ,' | | | || | / | || | \ :| ' | | . .:__,'| : ; | ; + ' : ;| | | | |. \ ' . \__\/: . .' : |__ | | : . ' / | ' : ;| | | | || : . || | ' | | | ' : |__ `---'. | + | | '| | | |/ \ \ ' ," .--.; || | '.'|' : |__ ' ; |: | | | '| | | |/ : |`-': | : ; ; | | | '.'| `--..`; + ' : || | |--' \ \ / / ,. |; : ;| | '.'|| | '/ ' ' : || | |--' : : : ' : `--' \ ; : ;.--,_ + ; |.' | |/ \ \ |; : .' \ , / ; : ;| : :| ; |.' | |/ | | : : , .-./ | , / | |`. + '---' '---' '---" | , .-./---`-' | , / \ \ / '---' '---' `---'.| `--`----' ---`-' `-- -`, ; + `--`---' ---`-' `----' `---` '---`" + + ''') From 79b3dfd39e509be5f136d641638b8ac37cc58c2d Mon Sep 17 00:00:00 2001 From: lesteveinix Date: Thu, 11 Oct 2018 18:47:51 +0800 Subject: [PATCH 3/9] Update exer_002.py --- exer_002.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/exer_002.py b/exer_002.py index e3bd602..a8720b5 100644 --- a/exer_002.py +++ b/exer_002.py @@ -12,4 +12,9 @@ if __name__ == '__main__': - # your code here \ No newline at end of file + def print_multiples(multiple, limit): + for x in range(1, limit//multiple + 1): + print(x*multiple) + + + print_multiples(7, 100) From b4b486a573faa85c2a7cf4c092c45958449baaec Mon Sep 17 00:00:00 2001 From: lesteveinix Date: Thu, 11 Oct 2018 18:48:25 +0800 Subject: [PATCH 4/9] Update exer_003.py --- exer_003.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/exer_003.py b/exer_003.py index 3072053..c42584c 100644 --- a/exer_003.py +++ b/exer_003.py @@ -22,4 +22,15 @@ if __name__ == '__main__': - # your code here \ No newline at end of file + while 1: + try: + x = input("Enter comma separated string: ") + + x = x.replace(" ", "") + x = x.split(',') + x = sorted(x) + x = ','.join(x) + + print(x) + except: + print('Oops, something went wrong XD') From b71b51805e249c2ff441f3354e0825ba18e59f65 Mon Sep 17 00:00:00 2001 From: omiplekevin Date: Fri, 12 Oct 2018 12:59:27 +0800 Subject: [PATCH 5/9] updated solution --- exer_001.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exer_001.py b/exer_001.py index 51cfbe4..f18c84d 100644 --- a/exer_001.py +++ b/exer_001.py @@ -17,13 +17,13 @@ if __name__ == '__main__': x = input() - if x in range(60, 75): + if x < 60 or x > 100: + print "Invalid Value" + elif x in range(60, 75): print "Derp!" elif x in range(75, 85): print "Good" elif x in range(85, 95): print "Very Good" elif x in range(95, 101): - print "Level Asian!" - else: - print "Invalid Value" \ No newline at end of file + print "Level Asian!" \ No newline at end of file From 871060d32576e080eb75d1bd9cea399dbc983d29 Mon Sep 17 00:00:00 2001 From: omiplekevin Date: Fri, 12 Oct 2018 13:44:49 +0800 Subject: [PATCH 6/9] updated solutions for exer_002.py and exer_003.py --- exer_002.py | 3 ++- exer_003.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/exer_002.py b/exer_002.py index e3bd602..ad3221c 100644 --- a/exer_002.py +++ b/exer_002.py @@ -12,4 +12,5 @@ if __name__ == '__main__': - # your code here \ No newline at end of file + for x in range(0,100,7): + print x \ No newline at end of file diff --git a/exer_003.py b/exer_003.py index 3072053..f952b49 100644 --- a/exer_003.py +++ b/exer_003.py @@ -22,4 +22,5 @@ if __name__ == '__main__': - # your code here \ No newline at end of file + x = raw_input().replace(',','') + print ','.join(sorted(set(x.lower()))) \ No newline at end of file From 1176ed6ed1bb72c70bb4c5035045dc318af274aa Mon Sep 17 00:00:00 2001 From: omiplekevin Date: Fri, 12 Oct 2018 13:52:50 +0800 Subject: [PATCH 7/9] updated solution for exer_003.py --- exer_003.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exer_003.py b/exer_003.py index f952b49..89a7ff0 100644 --- a/exer_003.py +++ b/exer_003.py @@ -22,5 +22,5 @@ if __name__ == '__main__': - x = raw_input().replace(',','') - print ','.join(sorted(set(x.lower()))) \ No newline at end of file + x = raw_input().replace(' ','').split(',') + print ','.join(sorted(x)) \ No newline at end of file From b751496105f3bb3595aefdd85090c05481c30fdb Mon Sep 17 00:00:00 2001 From: omiplekevin Date: Fri, 12 Oct 2018 17:56:06 +0800 Subject: [PATCH 8/9] updated email --- exer_002.py | 8 +++++--- exer_003.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/exer_002.py b/exer_002.py index ad3221c..0d62cf4 100644 --- a/exer_002.py +++ b/exer_002.py @@ -8,9 +8,11 @@ """ # your name and email address here -__author__ = 'xXLXx ' +__author__ = 'xXLXx ' if __name__ == '__main__': - for x in range(0,100,7): - print x \ No newline at end of file + mods = [x for x in range(0,100) if x % 7 == 0] + print(mods) + # for x in range(0,100,7): + # print x \ No newline at end of file diff --git a/exer_003.py b/exer_003.py index 89a7ff0..4e17c3e 100644 --- a/exer_003.py +++ b/exer_003.py @@ -18,7 +18,7 @@ # your name and email address here -__author__ = 'xXLXx ' +__author__ = 'xXLXx ' if __name__ == '__main__': From 96fa2f70f72c1ee612b33aa1c5b4dc4164008ca9 Mon Sep 17 00:00:00 2001 From: xXLXx Date: Tue, 16 Oct 2018 15:54:38 +0800 Subject: [PATCH 9/9] Add last exercises for slide 1 & 2 --- exer_004.py | 21 +++++++++++++++++++++ exer_005.py | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 exer_004.py create mode 100644 exer_005.py diff --git a/exer_004.py b/exer_004.py new file mode 100644 index 0000000..2058ff3 --- /dev/null +++ b/exer_004.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +""" +Exercise #4 + +Write a program that prints out the square of the first 20 integers +in a block such that the block has a dimension of 4x5. + + 1 4 9 16 + 25 36 49 64 + 81 100 121 144 +169 196 225 256 +289 324 361 400 +""" + + +# your name and email address here +__author__ = 'xXLXx ' + + +if __name__ == '__main__': + # your code here \ No newline at end of file diff --git a/exer_005.py b/exer_005.py new file mode 100644 index 0000000..2ceb2a0 --- /dev/null +++ b/exer_005.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +""" +Exercise #5: + +a program which determines whether the input string +is a palindrome or not. +(Disregard spaces) + +Example: + +Enter a string: This is a sample string. +>> False + +Enter a string: Rats live on no evil star +>> True +""" + + +# your name and email address here +__author__ = 'xXLXx ' + + +if __name__ == '__main__': + # your code here \ No newline at end of file