Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.17 KB

if_logic_30.md

File metadata and controls

43 lines (31 loc) · 1.17 KB

If Logic (30)

Problem

Use the programming interface to complete this task. You'll be given a list of numbers.

Input: A list of numbers, separated by commas.

Output: Print hiif the number is 0-50 (inclusive), hey if the number is 51-100 (inclusive), and hello if anything else. Each greeting should have a linebreak after it.

Read the input from a file called if-logic.in that's in the current working directory, and then write your output to a file called if-logic.out.

Hint

If you need help, try looking at the Python Tutorial in the Learn section!

Writeup

file1 = open("if-logic.in", 'r')
s = file1.read().strip()
a = s.split(",")
text = ""
for x in a:
  if int(x) >= 0 and int(x) <= 50:
    text += "hi\n"
  elif int(x) > 50 and int(x) <= 100:
    text += "hey\n"
  else:
    text += "hello\n"
file2 = open("if-logic.out", 'w')
file2.write(text)
file1.close()
file2.close()

##Flag easyctf{is_it_hi_or_hey_or_something_else}

External Writeups