top of page

Python Challenge

Updated: Apr 17, 2021



What I learning


1) Python programming basics

2) The Python Challenge Website level 0 - level 7

3) Devise and create a simple riddle inspired by the Python Challenge



Learning Materials



Python programming basics

1) Printing to the console, using quotes, indentation / blocks, string concatenation

2) Variables : ints, floats, strings, lists, tuples (read-only lists), accessing data in lists, dictionaries 3) Basic operators 4) Conditionals, loops, functions 5) For letter in 'Python': print 'Current Letter :', letter keywords, comments 6) Keywords, comments

7) Import

Python Challenge

Level 0


# Explore􏰀 First􏰙I Change 0 to 238 on the URL. After running, a reminder
# No... the 38 is a little bit above the 2...
# My second attempt was to take the result of 2 to the 38th power,
# and replace the 0 in the URL with the result of the calculation.
print(2**38)

274877906944

# Method 2: use pow() 
pow(2,38)

274877906944



Level 1



# Explore: The image lists 3 pairs, 'K->M', 'O->Q', 'E->G'. Each letter is
# everybody thinks twice before solving this:
# g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmg # gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle
# qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
# We need to decrypt this string, which contains the prompt information.
# Although my guess is successful, I think it is necessary to learn how to # the answer is change 'map' to 'ocr'
# To shift a character: 
ord('k')

107

ord('k') + 2

109

chr(ord('k') + 2)

'm'

# but it is not working for 'z'
chr(ord('z') + 2)

'|'

# Calculate the distance between ‘z’ and ‘a’ 
(ord('z') + 2) - ord('a')

27

# if it is larger than 26, go back to the beginning 
((ord('z') + 2) - ord('a')) % 26

1

# add that difference to 'a'
chr(((ord('z') + 2) - ord('a')) % 26 + ord('a'))

'b'

# translate the whole string 
result = "" for c in raw:
if c >= 'a' and c <= 'z':
result += chr(((ord(c) + 2) - ord('a')) % 26 + ord('a'))
else:
result += c
result

"i hope you didnt translate it by hand. thats what computers are for. doing itin

by hand is inefficient and that's why this text is so long. using stri ng.maketrans()

is recommended. now apply on the url."


.

.

.


Level 2 - Level 7




My own Python Riddle
guess = 0
while True == True:
print("What begins with an “e” and only contains one letter?") print("Type your guess,or type'help1','help2',or'I give up'below.") answer = input()
guess += 1
if answer == "An envelope":
print("You win􏲝")
print("It took you " + str(guess) + " guesses.") break
elif answer == "help1":
print("It is used to encapsulate things.")
elif answer == "help2":
print("It is related to the post office")
elif answer == "I give up":
print("The answer was an envelope !") break
else:
print("Try again!")

What begins with an “e” and only contains one letter? Type your guess,or

type'help1','help2',or'I give up'below. ear Try again! What begins with an “e” and only contains one letter? Type your guess,or

type'help1','help2',or'I give up'below. east Try again! What begins with an “e” and only contains one letter? Type your guess,or

type'help1','help2',or'I give up'below. help1 It is used to encapsulate things. What begins with an “e” and only contains one letter? Type your guess,or

type'help1','help2',or'I give up'below. help2 It is related to the post office What begins with an “e” and only contains one letter? Type your guess,or

type'help1','help2',or'I give up'below. An envelope You win􏲝 It took you 5 guesses.


Comments


bottom of page