### @export "setup" import fake_input # 동요 "Mary has a little lamb" input, input = fake_input.create( ['', '메리에겐 꼬마 양이 한 마리', '털은 눈처럼 하얗네', '게다가 맛있기까지']) ### @export "code" from sys import argv 스크립트, 파일_이름 = argv print(f"{파일_이름} 파일을 지우려 합니다.") print("취소하려면 CTRL-C (^C) 를 누르세요.") print("진행하려면 리턴 키를 누르세요.") input("?") print("파일 여는 중...") 목적지 = open(파일_이름, 'w', encoding='utf-8') print("파일 내용을 지웁니다. 안녕히!") 목적지.truncate() print("이제 세 줄에 들어갈 내용을 부탁드릴게요.") 줄1 = input("1줄: ") 줄2 = input("2줄: ") 줄3 = input("3줄: ") print("이 내용을 파일에 씁니다.")
### @export "fake" import fake_input input, input = fake_input.create(['38', '6\'2"', '180lbs']) ### @export "code" age = input("How old are you? ") height = input("How tall are you? ") weight = input("How much do you weigh? ") print(f"So, you're {age} old, {height} tall and {weight} heavy.")
### @export "fake" import fake_input input, input = fake_input.create([ '왼쪽', '곰 놀리기', '문 열기', '1000' '']) ### @export "code" from sys import exit def gold_room(): print("황금으로 가득 찬 방입니다. 얼마나 가져갈까요?") choice = input("> ") if "0" in choice or "1" in choice: how_much = int(choice) else: dead("인간이여, 숫자 쓰는 법부터 배우세요.") if how_much < 50: print("좋아, 욕심부리지 않는군요. 당신이 이겼습니다!") exit(0) else: dead("욕심쟁이 얼간이같으니!") def bear_room(): print("여기에는 곰이 한 마리 있습니다.") print("곰은 꿀을 잔뜩 들고 있습니다.")
### @export "fake" import fake_input input, input = fake_input.create(['1', '2', '']) ### @export "code" print("""You enter a dark room with two doors. Do you go through door #1 or door #2?""") door = input("> ") if door == "1": print("There's a giant bear here eating a cheese cake. What do you do?") print("1. Take the cake.") print("2. Scream at the bear.") bear = input("> ") if bear == "1": print("The bear eats your face off. Good job!") elif bear == "2": print("The bear eats your legs off. Good job!")
### @export "fake" import fake_input input, input = fake_input.create(['']) ### @export "code" from sys import argv from os.path import exists script, from_file, to_file = argv print(f"Copying from {from_file} to {to_file}") # we could do these two on one line, how? in_file = open(from_file) indata = in_file.read() print(f"The input file is {len(indata)} bytes long") print(f"Does the output file exist? {exists(to_file)}") print("Ready, hit RETURN to continue, CTRL-C to abort.") input() out_file = open(to_file, 'w') out_file.write(indata) print("Alright, all done.") out_file.close() in_file.close()
### @export "setup" import fake_input input, input = fake_input.create(['Yes', "San Francisco", 'Tandy 1000']) ### @export "code" from sys import argv script, user_name = argv prompt = '> ' print(f"Hi {user_name}, I'm the {script} script.") print("I'd like to ask you a few questions.") print(f"Do you like me {user_name}?") likes = input(prompt) print(f"Where do you live {user_name}?") lives = input(prompt) print("What kind of computer do you have?") computer = input(prompt) print(f""" Alright, so you said {likes} about liking me. You live in {lives}. Not sure where that is. And you have a {computer} computer. Nice. """)
### @export "fake" import fake_input input, input = fake_input.create(['dodge!']) ### @export "imports" from sys import exit from random import randint ### @export "scene_class" class Scene(object): def enter(self): print( "This scene is not yet configured. Subclass it and implement enter()." ) exit(1) ### @export "engine_class" class Engine(object): def __init__(self, scene_map): self.scene_map = scene_map def play(self): current_scene = self.scene_map.opening_scene() last_scene = self.scene_map.next_scene('finished')
### @export "setup" import fake_input input, input = fake_input.create(['ex15_sample.txt']) ### @export "code" from sys import argv script, filename = argv txt = open(filename) print(f"Here's your file {filename}:") print(txt.read()) print("Type the filename again:") file_again = input('>') txt_again = open(file_again) print(txt_again.read())
### @export "fake" import fake_input input, input = fake_input.create(['38', '188cm', '82kg']) ### @export "code" 나이 = input("몇 살이죠? ") 키 = input("키는 얼마죠? ") 몸무게 = input("몸무게는 얼마죠? ") print(f"네, 나이는 {나이}살, 키는 {키}, 몸무게는 {몸무게}이네요.") # see if this is nessessary #print "뜬금없지만, 태양의 각지름은 %r입니다." % '''32'10"'''
### @export "setup" import fake_input input, input = fake_input.create(['네', "샌프란시스코", 'Tandy 1000']) ### @export "code" from sys import argv 스크립트, 사용자_이름 = argv 프롬프트 = '> ' print(f"안녕 {사용자_이름}, 나는 {스크립트} 스크립트야.") print("몇 가지 질문을 할게.") print(f"{사용자_이름}, 나를 좋아해?") 좋아 = input(프롬프트) print(f"{사용자_이름}, 어디에 살아?") 살아 = input(프롬프트) print("무슨 컴퓨터를 갖고 있어?") 컴퓨터 = input(프롬프트) print(f""" 좋아, 나를 좋아하냐는 질문에는 {좋아}. {살아}에 살아. 어딘지는 모르겠지만. 그리고 {컴퓨터} 컴퓨터를 가졌어. 근사한걸. """)
### @export "setup" import fake_input input, input = fake_input.create([ '', 'Marry had a little lamb', 'Its fleece was white as snow', 'It was also tasty' ]) ### @export "code" from sys import argv script, filename = argv print(f"We're going to erase {filename}.") print("If you don't want that, hit CTRL-C (^C).") print("If you do want that, hit RETURN.") input("?") print("Opening the file ...") target = open(filename, 'w') print("Truncating the file. Goodbye!") target.truncate() print("Now I'm going to ask you for three lines.") line1 = input("line 1: ") line2 = input("line 2: ") line3 = input("line 3: ") print("I'm going to write these to the file.")
### @export "fake" import fake_input input, input = fake_input.create(['회피!']) ### @export "imports" from sys import exit from random import randint from textwrap import dedent ### @export "scene_class" class Scene(object): def enter(self): print("아직 만들지 않은 장면입니다.") print("상속해 enter()를 구현하세요.") exit(1) ### @export "engine_class" class Engine(object): def __init__(self, scene_map): self.scene_map = scene_map def play(self): current_scene = self.scene_map.opening_scene() last_scene = self.scene_map.next_scene('finished')
### @export "fake" import fake_input input, input = fake_input.create( ['left', 'taunt bear', 'open door', '1000' '']) ### @export "code" from sys import exit def gold_room(): print("This room is full of gold. How much do you take?") choice = input("> ") if "0" in choice or "1" in choice: how_much = int(choice) else: dead("Man, learn to type a number.") if how_much < 50: print("Nice, you're not greedy, you win!") exit(0) else: dead("You greedy bastard!") def bear_room(): print("There is a bear here.") print("The bear has a bunch of honey.") print("The fat bear is in front of another door.")