🐍Python Basics

Using a web-based code editor, learn the basics of Python and put your knowledge into practice by eventually coding a short Bitcoin investment project.

https://tryhackme.com/room/pythonbasics
Room Attributes
Value

Subscription Required

False [Free]

Type

Walkthrough

Difficulty

Info

Tags

Python, Programming, Bitcoin

Task 1 - Introduction to Python

Run what's currently in the code editor by clicking the green "Run Code" button (on the right-hand side of your screen), and move onto the next task.

Task 2 - Hello World

On the code editor, print "Hello World". What is the flag?

Reveal Flag đŸš©

đŸš©THM{PRINT_STATEMENTS}

Task 3 - Mathematical Operators

In the code editor, print the result of 21 + 43. What is the flag?

Reveal Flag đŸš©

đŸš©THM{PRINT_STATEMENTS}

Reveal Flag đŸš©

đŸš©THM{SUBTRCT}

Reveal Flag đŸš©

đŸš©THM{MULTIPLICATION_PYTHON}

Reveal Flag đŸš©

đŸš©THM{EXP0N3NT_POWER}

Task 4 - Variables and Data Types

In the code editor, create a variable called height and set its initial value to 200.

On a new line, add 50 to the height variable.

On another new line, print out the value of height. What is the flag that appears?

Reveal Flag đŸš©

đŸš©THM{VARIABL3S}

Task 5 - Logical and Boolean Operators

Read the above section.

Task 6 - Shipping Project Introduction to If Statements

In this exercise, we will code a small application that calculates and outputs the shipping cost for a customer based on how much they've spent. In the code editor, click on the "shipping.py" tab and follow the instructions to complete this task.

Once you've written the application in the code editor's shipping.py tab, a flag will appear, which is the answer to this question.

Reveal Flag đŸš©

đŸš©THM{IF_STATEMENT_SHOPPING}

In shipping.py, on line 12 (when using the Code Editor's Hint), change the customer_basket_cost variable to 101 and re-run your code. You will get a flag (if the total cost is correct based on your code); the flag is the answer to this question.

Reveal Flag đŸš©

đŸš©THM{MY_FIRST_APP}

Task 7 - Loops

On the code editor, click back on the "script.py" tab and code a loop that outputs every number from 0 to 50.

Reveal Flag đŸš©

đŸš©THM{L00PS_WHILE_FOR}

Task 8 - Bitcoin Project Introduction to Functions

Once you've written the bitcoinToUSD function, use it to calculate the value of your Bitcoin in USD, and then create an if statement to determine if the value falls below $30,000; if it does, output a message to alert you (via a print statement).

Reveal Flag đŸš©

đŸš©THM{BITC0IN_INVESTOR}

1 Bitcoin is now worth $25,000. In the code editor on line 14, update the bitcoin_to_usd variable value to 25000 and see if your Python program recognises that your investment is below the $30,000 threshold.

Task 9 - Files

In the code editor, write Python code to read the flag.txt file. What is the flag in this file?

Reveal Flag đŸš©

đŸš©THM{F1LE_R3AD}

Task 10 - Imports

Read the task and run the Python example code above in the code editor on the right.

Last updated