0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

一人アドカレAdvent Calendar 2024

Day 13

【TryHackMe】Python Basics:Walkthrough

Posted at

概要

TryHackMe「Python Basics」のWalkthroughです。

Task2

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

Hint.In the code editor (right-hand side), replace "Learn security with TryHackMe" with "Hello World" and click the green run code button.

print()Hello Worldを出力します。

print("Hello World")

image.png

A.THM{PRINT_STATEMENTS}

Task3

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

Hint.In the code editor on the right, write the following: print(21 + 43)

print(21 + 43)

image.png

A.THM{ADDITI0N}

Q2.Print the result of 142 - 52. What is the flag?

print(142 - 52)

image.png

A.THM{SUBTRCT}

Q3.Print the result of 10 * 342. What is the flag?

print(10 * 342)

image.png

A.THM{MULTIPLICATION_PYTHON}

Q4.Print the result of 5 squared. What is the flag?

Hint.5 ** 2

print(5 ** 2)

image.png

A.THM{EXP0N3NT_POWER}

Task4

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

height = 200
height += 50
print(height)

image.png

A.THM{VARIABL3S}

Task6

Q2.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.

Hint.Need a hint? On the code editor, to the left of the "Run Code" button, there will be a hint button to help you get started.

shipping_cost_per_kg = 1.20
customer_basket_cost = 34
customer_basket_weight = 44

if(customer_basket_cost >= 100):
  print('Free shipping!')
else:
  shipping_cost = customer_basket_weight * shipping_cost_per_kg
  customer_basket_cost = shipping_cost + customer_basket_cost

print("Total basket cost including shipping is " + str(customer_basket_cost))

image.png

A.THM{IF_STATEMENT_SHOPPING}

Q3.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.

customer_basket_cost101に変更します。

shipping_cost_per_kg = 1.20
customer_basket_cost = 101
customer_basket_weight = 44

if(customer_basket_cost >= 100):
  print('Free shipping!')
else:
  shipping_cost = customer_basket_weight * shipping_cost_per_kg
  customer_basket_cost = shipping_cost + customer_basket_cost

print("Total basket cost including shipping is " + str(customer_basket_cost))

image.png

A.THM{MY_FIRST_APP}

Task7

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

Hint.You can use a for loop or while loop, but it must print from 0 to 50.

for i in range(51):
  print(i)

image.png

A.THM{L00PS_WHILE_FOR}

Task8

Q1.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).

Hint.Make sure your Python function has the name bitcoinToUSD and uses the parameter names bitcoin_amount and bitcoin_value_usd.

investment_in_bitcoin = 1.2
bitcoin_to_usd = 40000

# 1) write a function to calculate bitcoin to usd
def bitcoinToUSD(bitcoin_amount, bitcoin_value_usd):
  usd_value = bitcoin_amount * bitcoin_value_usd
  return usd_value

investment_in_usd = bitcoinToUSD(investment_in_bitcoin, bitcoin_to_usd)
if investment_in_usd <= 30000:
  print("Investment below $30,000! SELL!")
else:
  print("Investment above $30,000")

image.png

A.THM{BITC0IN_INVESTOR}

Task9

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

f = open("flag.txt", "r")
print(f.read())

image.png

A.THM{F1LE_R3AD}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?