Python Basics (TryHackMe)

I'm currently learning the fundamentals and introduction to cybersecurity pathways on TryHackMe(THM). This has given me a chance to learn the fundamentals of Python and answer some questions. With time being limited I won't be able to break the sections into detail this will be more of answers to the various sections of the Python Basics room.
On the code editor, print "Hello World". What is the flag?
THM{PRINT_STATEMENTS}print("Hello World")In the code editor, print the result of 21 + 43. What is the flag?
THM{ADDITI0N}print(21 + 43)Print the result of 142 - 52. What is the flag?
THM{SUBTRCT}print(142 - 52)Print the result of 10 * 324. What is the flag?
THM{MULTIPLICATION_PYTHON}print(10 * 324)Print the result of 5 squared. What is the flag?
THM{EXP0N3NT_POWER}print(5 ** 2)On another new line, print out the value of height. What is the flag that appears?
THM{VARIABL3S}height = 200 height = height + 50 print(height)On the code editor, click back on the "script.py" tab and code a loop that outputs every number from 0 to 50.
THM{L00PS_WHILE_FOR}for i in range(51): print(i)You've invested in Bitcoin and want to write a program that tells you when the value of Bitcoin falls below a particular value in dollars.
THM{BITC0IN_INVESTOR}In the code editor, click on the bitcoin.py tab. Write a function called bitcoinToUSD with two parameters: bitcoin_amount, the amount of Bitcoin you own, and bitcoin_value_usd, the value of bitcoin in USD. The function should return usd_value, which is your bitcoin value in USD (to calculate this, in the function, you times bitcoin_amount variable by bitcoin_value_usd variable and return the value). The start of the function should look like this:
def bitcoinToUSD(bitcoin_amount, bitcoin_value_usd): usd_value = bitcoin_amount * bitcoin_value_usd return usd_valueinvestment_in_bitcoin = 1.2 bitcoin_to_usd = 40000 # Calculate the value of your Bitcoin in USD my_bitcoin_value = bitcoinToUSD(investment_in_bitcoin, bitcoin_to_usd) # Check if the value falls below $30,000 if my_bitcoin_value < 30000: print("Alert: Your Bitcoin value (${my_bitcoin_value}) has fallen below $30,000!") else: print("Your Bitcoin value is ${my_bitcoin_value}")In the code editor, write Python code to read the flag.txt file. What is the flag in this file?
THM{F1LE_R3AD}
# Write your python code here
f = open("flag.txt", "r")
print(f.read())
Thanks for reading through my article. At the moment I hope that I will remain consistent in this learning journey and keep practicing as the days and months come by.




