labNo float64 1 10 ⌀ | taskNo float64 0 4 ⌀ | questioner stringclasses 2
values | question stringlengths 9 201 | code stringlengths 18 30.3k | startLine float64 0 192 ⌀ | endLine float64 0 196 ⌀ | questionType stringclasses 4
values | answer stringlengths 2 905 | src stringclasses 3
values | code_processed stringlengths 12 28.3k ⌀ | id stringlengths 2 5 ⌀ | raw_code stringlengths 20 30.3k ⌀ | raw_comment stringlengths 10 242 ⌀ | comment stringlengths 9 207 ⌀ | q_code stringlengths 66 30.3k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 0 | TA | Please explain what the flag is for Tasks 1 and 2. | from cs1robots import *
load_world('worlds/harvest3.wld')
def move(n=1):
for i in range(n):
h.move()
def left():
h.turn_left()
def right():
for i in range(3):
left()
h = Robot(beepers=36)
h.set_trace('blue')
move()
def oneStep():
if h.on_beeper():
h.pick_beeper()
move()
de... | 20 | 35 | variable | Yes, in 1,2, the flag is a variable indicating whether the current line is an even number or an odd number, and is used to determine whether the current line ends and rotates left or right. | cs1qa | null | null | null | null | null | Question:
Please explain what the flag is for Tasks 1 and 2.
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
def move(n=1):
for i in range(n):
h.move()
def left():
h.turn_left()
def right():
for i in range(3):
left()
h = Robot(beepers=36)
h.set_trace('blue')
move()
def o... |
2 | 0 | TA | Could you briefly explain what the move_and_pick function does? | from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot()
hubo.set_trace('blue')
def move_and_pick() :
hubo.move()
if hubo.on_beeper() :
hubo.pick_beeper()
def turn_right():
hubo.turn_left()
hubo.turn_left()
hubo.turn_left()
for i in range (2):
while hubo.front_... | 5 | 8 | variable | It is a function that moves one space and picks up if there is a beeper in the moved position. | cs1qa | null | null | null | null | null | Question:
Could you briefly explain what the move_and_pick function does?
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot()
hubo.set_trace('blue')
def move_and_pick() :
hubo.move()
if hubo.on_beeper() :
hubo.pick_beeper()
def turn_right():
hubo.turn_left()
... |
6 | 2 | TA | check function
Please explain | from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct_list = []
def initialize():
# initial... | 81 | 101 | variable | After adding the two drawn cards to the correct list, if they are the same, print true and send out true, and if the two cards are different, remove them from the correct list and send false | cs1qa | null | null | null | null | null | Question:
check function
Please explain
Code:
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
co... |
8 | 2 | TA | What about before the decimal point? | import elice_utils
f = open('tpmon.txt', 'r')
lines = f.readlines()
f.close()
avg_tp = []
year = 1723
f = open('tpmon.csv', 'w')
for line in lines[1:]:
temporary_list = line.split(' ')
for i in range(temporary_list.count('')):
temporary_list.remove('')
temporary_list.remove('\n')
tempora... | 27 | 27 | variable | Make the string length 6 and align it to the far right. | cs1qa | null | null | null | null | null | Question:
What about before the decimal point?
Code:
import elice_utils
f = open('tpmon.txt', 'r')
lines = f.readlines()
f.close()
avg_tp = []
year = 1723
f = open('tpmon.csv', 'w')
for line in lines[1:]:
temporary_list = line.split(' ')
for i in range(temporary_list.count('')):
temporary_list.rem... |
6 | 2 | TA | Can you briefly explain the role of correct_list? | from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct_list = []
def initialize():
# initial... | 0 | 150 | variable | Matched number pad keeps showing matched cards as a list of numbers, used to indicate You got-pairs | cs1qa | null | null | null | null | null | Question:
Can you briefly explain the role of correct_list?
Code:
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pa... |
2 | 0 | TA | What is the role of the one_round() function in Task1? | from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot(beepers=1)
hubo.set_trace('blue')
def turn_right():
hubo.turn_left()
hubo.turn_left()
hubo.turn_left()
def collect_beeper():
if hubo.on_beeper():
hubo.pick_beeper()
def go_straight():
for i in range(5):
hubo.move()
... | 17 | 27 | variable | In task 1, the robot repeats going right and left, so we made it a function and repeated it. | cs1qa | null | null | null | null | null | Question:
What is the role of the one_round() function in Task1?
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot(beepers=1)
hubo.set_trace('blue')
def turn_right():
hubo.turn_left()
hubo.turn_left()
hubo.turn_left()
def collect_beeper():
if hubo.on_beeper():
hubo.pick_... |
9 | 1 | TA | Please explain how you implemented hand_value in No. 2~! | import random
from cs1graphics import *
img_path = './images/'
suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
face_names = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
value = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
bj_board = Canvas(600, 400, 'dark green', 'Black Jac... | 47 | 58 | variable | hand_value was added by extracting only the values of the cards in the hand list. | cs1qa | null | null | null | null | null | Question:
Please explain how you implemented hand_value in No. 2~!
Code:
import random
from cs1graphics import *
img_path = './images/'
suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
face_names = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
value = [11, 2, 3, 4, 5, 6, 7, 8... |
3 | 3 | TA | Yes, simply explain closing_door! | from cs1robots import *
# Your code must work for both of the worlds below.
load_world('worlds/rain1.wld')
# load_world('worlds/rain2.wld')
# Initialize your robot at the door of the house.
my_robot = Robot(beepers=100, avenue=2, street=6, orientation='E')
# Now close all the windows in the house!
my_robot.set_pause... | 15 | 27 | variable | Because all the windows are 1 space
If the left side is empty, drop the beeper
Even after moving forward, if it is empty, it is judged as a corner, not a window.
Come back and retrieve the beeper and turn
Or keep going
It’s the function set up like that | cs1qa | null | null | null | null | null | Question:
Yes, simply explain closing_door!
Code:
from cs1robots import *
# Your code must work for both of the worlds below.
load_world('worlds/rain1.wld')
# load_world('worlds/rain2.wld')
# Initialize your robot at the door of the house.
my_robot = Robot(beepers=100, avenue=2, street=6, orientation='E')
# Now c... |
10 | 0 | TA | Briefly explain the three methods of butterfly among the implemented classes. | from cs1graphics import *
from time import sleep
_scene = None
_world = None
def create_world():
global _scene, _world
if _scene:
raise RuntimeError("A world already exists!")
_world = _World(500, 300)
_scene = Canvas(_world.width, _world.height)
_scene.setTitle("Butterfly")
_scene.set... | 47 | 71 | variable | Fly makes the wings move back and forth in place, and move moves the wings as much as x, y and moves at constant speed over 5 seconds, and change is a method to change the wings to the desired color. | cs1qa | null | null | null | null | null | Question:
Briefly explain the three methods of butterfly among the implemented classes.
Code:
from cs1graphics import *
from time import sleep
_scene = None
_world = None
def create_world():
global _scene, _world
if _scene:
raise RuntimeError("A world already exists!")
_world = _World(500, 300)... |
2 | 4 | TA | What is the role of t in your code? | from cs1robots import *
# Your code must work for empty worlds of all possible sizes.
create_world(avenues=10, streets=6)
# create_world(avenues=11, streets=8)
# create_world(avenues=6, streets=9)
# create_world(avenues=1, streets=3)
# create_world(avenues=2, streets=1)
# create_world(avenues=1, streets=2)
# ...
hub... | 37 | 47 | variable | It is a variable indicating how far the vertical line has gone,
Except for mx1, it excludes the first left corner
To be able to finish when you get to the right corner! | cs1qa | null | null | null | null | null | Question:
What is the role of t in your code?
Code:
from cs1robots import *
# Your code must work for empty worlds of all possible sizes.
create_world(avenues=10, streets=6)
# create_world(avenues=11, streets=8)
# create_world(avenues=6, streets=9)
# create_world(avenues=1, streets=3)
# create_world(avenues=2, str... |
1 | 4 | TA | What is the role of carrots? | from cs1robots import *
load_world("worlds/harvest2.wld")
hubo = Robot()
carrots = 0
marker = 0
hubo.set_trace("blue") ##optional
def turnright():
for i in range(3):
hubo.turn_left()
def proceed():
for i in range(2):
hubo.move()
#before collecting halfway
def righty():
global carr... | 4 | 104 | variable | carrots is the number of beepers the robot has collected | cs1qa | null | null | null | null | null | Question:
What is the role of carrots?
Code:
from cs1robots import *
load_world("worlds/harvest2.wld")
hubo = Robot()
carrots = 0
marker = 0
hubo.set_trace("blue") ##optional
def turnright():
for i in range(3):
hubo.turn_left()
def proceed():
for i in range(2):
hubo.move()
#before ... |
5 | 0 | TA | can you briefly explain task1 withdrawal function?? | balance = 0
def deposit(money) :
global balance
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
balance=balance+money
print("You deposited {} won".format(money))
# Do something on here !
... | 16 | 32 | variable | withdrawal is a function that subtracts by the number you entered, but issues a warning when the subtraction number is larger. | cs1qa | null | null | null | null | null | Question:
can you briefly explain task1 withdrawal function??
Code:
balance = 0
def deposit(money) :
global balance
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
balance=balance+money
pri... |
3 | 1 | TA | For task 2, why do you have both line 18-19 and line 21-22? | from cs1robots import *
# Your code must work for all world files below.
# load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def uturn():
for i in range(2):
turn_right()
while hubo.fro... | 17 | 21 | reasoning | Just to pick all the beepers and the reason that line 21-22 exists is that we have to make sure that the robot still pick the beeper(s) at the point which front is not clear too | cs1qa | null | null | null | null | null | Question:
For task 2, why do you have both line 18-19 and line 21-22?
Code:
from cs1robots import *
# Your code must work for all world files below.
# load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_... |
3 | 2 | TA | What is the meaning of the turn variable used here? | from cs1robots import *
# Your code must work with any of the world files below.
load_world('worlds/trash3.wld')
# load_world('worlds/trash4.wld')
hubo = Robot()
hubo.set_trace("red")
# hubo.set_pause(1)
turn = 0
def turn_right():
for i in range(3):
hubo.turn_left()
def move():
while hubo.f... | 22 | 47 | variable | When the turn is even number, it turns to the right, and when the turn is odd number, it turns to the left. | cs1qa | null | null | null | null | null | Question:
What is the meaning of the turn variable used here?
Code:
from cs1robots import *
# Your code must work with any of the world files below.
load_world('worlds/trash3.wld')
# load_world('worlds/trash4.wld')
hubo = Robot()
hubo.set_trace("red")
# hubo.set_pause(1)
turn = 0
def turn_right():
for i in r... |
10 | 0 | TA | Would you please write in this chat room as much detail as possible about what animation you made and how you met each requirement in the description? | from cs1graphics import *
from time import sleep
_scene = None
_world = None
def create_world():
global _scene, _world
if _scene:
raise RuntimeError("A world already exists!")
_world = _World(500, 300)
_scene = Canvas(_world.width, _world.height)
_scene.setTitle("Mario World")
_world.d... | 0 | 167 | code_explain | The overall animation content is an animation in which the apple on the tree falls and crushes due to the rain falling and the tree shakes. So, first, the gel first expresses the rain, and the leaves of the tree move on the canvas and the apple falls and crushes. | cs1qa | null | null | null | null | null | Question:
Would you please write in this chat room as much detail as possible about what animation you made and how you met each requirement in the description?
Code:
from cs1graphics import *
from time import sleep
_scene = None
_world = None
def create_world():
global _scene, _world
if _scene:
ra... |
1 | 3 | TA | Please briefly explain the behavior of next_line and next_line2 in task 4! | from cs1robots import *
# create_world()
# load_world('worlds/world_file_name.wld')
load_world('worlds/harvest1.wld')
hubo = Robot()
hubo.set_trace('blue')
hubo.move()
def turn_right():
for i in range(3):
hubo.turn_left()
def harvest_one_line():
for i in range(5):
hubo.pick_beeper()
... | 19 | 27 | variable | next_line is an action to move from the odd numbered line to the even numbered line
next_line2 moves from even to odd lines! | cs1qa | null | null | null | null | null | Question:
Please briefly explain the behavior of next_line and next_line2 in task 4!
Code:
from cs1robots import *
# create_world()
# load_world('worlds/world_file_name.wld')
load_world('worlds/harvest1.wld')
hubo = Robot()
hubo.set_trace('blue')
hubo.move()
def turn_right():
for i in range(3):
hubo.t... |
1 | 3 | TA | In number 4, there are harvest and harvest2. What does harvest2 do?? | from cs1robots import*
load_world('worlds/harvest1.wld')
hubo=Robot(beepers=1)
def turn_right():
for i in range(3):
hubo.turn_left()
def mnp():
hubo.pick_beeper()
hubo.move()
def harvest():
for i in range(5):
mnp()
hubo.pick_beeper()
def harvest2():
hubo.move()
hubo.turn_lef... | 10 | 22 | variable | Harvest is to harvest a row, and harvest 2 is to harvest by round trip! | cs1qa | null | null | null | null | null | Question:
In number 4, there are harvest and harvest2. What does harvest2 do??
Code:
from cs1robots import*
load_world('worlds/harvest1.wld')
hubo=Robot(beepers=1)
def turn_right():
for i in range(3):
hubo.turn_left()
def mnp():
hubo.pick_beeper()
hubo.move()
def harvest():
for i in range(5)... |
5 | 0 | TA | Is there any reason I used if-pass in task1?? | balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
if money>0:
pass
print("You deposited " + str(m... | 46 | 47 | reasoning | I don't think I need it | cs1qa | null | null | null | null | null | Question:
Is there any reason I used if-pass in task1??
Code:
balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
... |
1 | 4 | TA | Could you explain the left_up and right_down functions? | from cs1robots import *
load_world('worlds/harvest2.wld')
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
for i in range(5):
hubo.move()
hubo.turn_left()
hubo.move()
hubo.turn_left()
def left_up():
for i in range(5):
hubo.pick_beeper()
hu... | 16 | 29 | variable | Left up is a function that collects beepers by stepping up to the left by 5 spaces, and left down is a function that collects beepers by stepping down to the right by 5 spaces. | cs1qa | null | null | null | null | null | Question:
Could you explain the left_up and right_down functions?
Code:
from cs1robots import *
load_world('worlds/harvest2.wld')
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
for i in range(5):
hubo.move()
hubo.turn_left()
hubo.move()
hubo.turn_left()
... |
3 | 4 | TA | In number 5, explain lines 19-24! | from cs1media import *
# This code converts an image into a black & white poster.
threshold1 = 100
threshold2 = 200
white = (255, 255, 255)
black = (0, 0, 0)
yellow = (255,255,0)
blue = (0,0,255)
green = (0,255,0)
image = load_picture('./images/pikachu.jpg')
width, height = image.size()
for y in range(height):
f... | 18 | 23 | code_explain | For a very bright color, I set the threshold to 200 so that if it is larger than 200, yellow appears, and if it is a very dark color, it should be close to 0. | cs1qa | null | null | null | null | null | Question:
In number 5, explain lines 19-24!
Code:
from cs1media import *
# This code converts an image into a black & white poster.
threshold1 = 100
threshold2 = 200
white = (255, 255, 255)
black = (0, 0, 0)
yellow = (255,255,0)
blue = (0,0,255)
green = (0,255,0)
image = load_picture('./images/pikachu.jpg')
width,... |
1 | 0 | TA | I think you wrote the code separately for only the last half of the 4 laps. Can I ask why? | from cs1robots import *
create_world()
hubo=Robot()
hubo.turn_left()
hubo.set_trace('blue')
def turn_right():
for i in range (3):
hubo.turn_left()
for i in range(4):
for j in range(9):
hubo.move()
turn_right()
hubo.move()
turn_right()
for k in range(9):
hubo.move()
... | 11 | 29 | reasoning | Lastly, the path was shorter than the one in front, so if it moved like in the loop, it hit the wall and did it separately. | cs1qa | null | null | null | null | null | Question:
I think you wrote the code separately for only the last half of the 4 laps. Can I ask why?
Code:
from cs1robots import *
create_world()
hubo=Robot()
hubo.turn_left()
hubo.set_trace('blue')
def turn_right():
for i in range (3):
hubo.turn_left()
for i in range(4):
for j in range(9):
... |
3 | 1 | TA | Please also briefly explain the reason why you should use the while statement, not the for statement loop, in the process of picking up the beeper. | from cs1robots import *
# Your code must work for all world files below.
# load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
hubo = Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def move_and_pick():
for i in range(9):
hubo.move()
... | 15 | 16 | reasoning | When picking up a beeper, it is necessary to give a beeper until there is no beeper, so we used a while statement that repeats while satisfying the condition, not for repeating a certain number. | cs1qa | null | null | null | null | null | Question:
Please also briefly explain the reason why you should use the while statement, not the for statement loop, in the process of picking up the beeper.
Code:
from cs1robots import *
# Your code must work for all world files below.
# load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
hubo = Ro... |
1 | 3 | TA | In number 4, there are harvest and harvest2. What does harvest2 do?? | from cs1robots import*
load_world('worlds/harvest1.wld')
hubo=Robot(beepers=1)
def turn_right():
for i in range(3):
hubo.turn_left()
def mnp():
hubo.pick_beeper()
hubo.move()
def harvest():
for i in range(5):
mnp()
hubo.pick_beeper()
def harvest2():
hubo.move()
hubo.turn_lef... | 10 | 22 | variable | Harvest is to harvest a row, and harvest 2 is to harvest by round trip! | cs1qa | null | null | null | null | null | Question:
In number 4, there are harvest and harvest2. What does harvest2 do??
Code:
from cs1robots import*
load_world('worlds/harvest1.wld')
hubo=Robot(beepers=1)
def turn_right():
for i in range(3):
hubo.turn_left()
def mnp():
hubo.pick_beeper()
hubo.move()
def harvest():
for i in range(5)... |
5 | 0 | TA | Please explain how you used the global variable in task 1! | balance = 0
def deposit(money):
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
# Do something on here !
global balance
balance = balance ... | 3 | 36 | variable | By specifying the balance as a global variable, all variables can be used in each function, and this is called the bank's remaining money. | cs1qa | null | null | null | null | null | Question:
Please explain how you used the global variable in task 1!
Code:
balance = 0
def deposit(money):
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
##########... |
5 | 0 | TA | Can you explain the function of global keyword in Task 1? | balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
# Do something on here !
global balance
balance = ... | 12 | 14 | variable | Since balance is a global variable, in order to change its value within the function, you must specify the global variable balance using the global keyword. | cs1qa | null | null | null | null | null | Question:
Can you explain the function of global keyword in Task 1?
Code:
balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
###... |
2 | 4 | TA | Next, please explain the last task 5 | from cs1robots import *
# Your code must work for empty worlds of all possible sizes.
create_world(avenues=10, streets=10)
# create_world(avenues=11, streets=8)
# create_world(avenues=6, streets=9)
# create_world(avenues=1, streets=3)
# create_world(avenues=2, streets=1)
# create_world(avenues=1, streets=2)
# ...
ti... | 17 | 41 | code_explain | We defined a function to move one line and a function to move around, and in order not to collide with the wall, the condition that there is no wall on the side was hung as a while. | cs1qa | null | null | null | null | null | Question:
Next, please explain the last task 5
Code:
from cs1robots import *
# Your code must work for empty worlds of all possible sizes.
create_world(avenues=10, streets=10)
# create_world(avenues=11, streets=8)
# create_world(avenues=6, streets=9)
# create_world(avenues=1, streets=3)
# create_world(avenues=2, s... |
1 | 3 | TA | Why is the condition checked??? | from cs1robots import *
class Superbot(Robot):
def turn_right(self):
for _ in range(3):
self.turn_left()
def turn_around(self):
for _ in range(2):
self.turn_left()
load_world("worlds/harvest1.wld")
hubo=Superbot()
while True:
if hubo.on_beeper():
... | 19 | 28 | reasoning | Since the x value does not change even after the robot rotates, the direction is also checked. | cs1qa | null | null | null | null | null | Question:
Why is the condition checked???
Code:
from cs1robots import *
class Superbot(Robot):
def turn_right(self):
for _ in range(3):
self.turn_left()
def turn_around(self):
for _ in range(2):
self.turn_left()
load_world("worlds/harvest1.wld")
hubo=Su... |
1 | 0 | TA | if i<4:
hubo.turn_left()
hubo.move()
Could you please explain why you added this part? | from cs1robots import *
create_world()
hubo = Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def go_straight():
for i in range(9):
hubo.move()
for i in range(5):
hubo.turn_left()
go_straight()
turn_right()
hubo.move()
... | 22 | 24 | reasoning | If i=4, there is no more space left on the right, so I tried to stop the code | cs1qa | null | null | null | null | null | Question:
if i<4:
hubo.turn_left()
hubo.move()
Could you please explain why you added this part?
Code:
from cs1robots import *
create_world()
hubo = Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def go_straight():
for i in range(9):
... |
8 | 1 | TA | In Task2, when you split, you split with ", not ". What is the reason? | file=open('average-latitude-longitude-countries.csv',"r")
list_all=[]
for line in file:
if line.strip()=='"ISO 3166 Country Code","Country","Latitude","Longitude"':
continue
list_splited=line.strip().split('"')
list_all.append((list_splited[1],list_splited[3],float(list_splited[4].split(",")[1]), fl... | 5 | 5 | reasoning | This is to return a new list divided by " | cs1qa | null | null | null | null | null | Question:
In Task2, when you split, you split with ", not ". What is the reason?
Code:
file=open('average-latitude-longitude-countries.csv',"r")
list_all=[]
for line in file:
if line.strip()=='"ISO 3166 Country Code","Country","Latitude","Longitude"':
continue
list_splited=line.strip().split('"')
... |
2 | 4 | TA | What function shuttle_run does in Task 5? | from cs1robots import *
# Your code must work for empty worlds of all possible sizes.
# create_world(avenues=10, streets=10)
# create_world(avenues=11, streets=8)
# create_world(avenues=6, streets=9)
# create_world(avenues=1, streets=3)
# create_world(avenues=2, streets=1)
# create_world(avenues=1, streets=2)
create_... | 20 | 30 | variable | This function is set to go up, move one line to the right in front of the wall and come down again.
However, because the number of passages has not been decided
If it becomes impossible to move one line to the right from the top, it is set to stop at that position. | cs1qa | null | null | null | null | null | Question:
What function shuttle_run does in Task 5?
Code:
from cs1robots import *
# Your code must work for empty worlds of all possible sizes.
# create_world(avenues=10, streets=10)
# create_world(avenues=11, streets=8)
# create_world(avenues=6, streets=9)
# create_world(avenues=1, streets=3)
# create_world(avenu... |
9 | 1 | student | But what's the difference between the deck of the main function and the deck of create_deck? | import random
from cs1graphics import *
img_path = './images/'
suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
face_names = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
value = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
bj_board = Canvas(600, 400, 'dark green', 'Black Jac... | null | null | code_understanding | The deck of the main function and the deck of the create_deck function are the same after all! | cs1qa | null | null | null | null | null | Question:
But what's the difference between the deck of the main function and the deck of create_deck?
Code:
import random
from cs1graphics import *
img_path = './images/'
suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
face_names = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'Kin... |
6 | 2 | TA | Can you briefly explain the role of correct_list? | from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct_list = []
def initialize():
# initial... | 104 | 108 | variable | Matched number pad keeps showing matched cards as a list of numbers, used to indicate You got-pairs | cs1qa | null | null | null | null | null | Question:
Can you briefly explain the role of correct_list?
Code:
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pa... |
6 | 0 | TA | I'll explain task 1! | def fibonacci(upper_bound):
l=[0,1]
while (l[len(l)-2]+l[len(l)-1])<upper_bound:
l.append(l[len(l)-2]+l[len(l)-1])
return l
print(fibonacci(1000))
| 0 | 7 | code_explain | Task 1 is to put 0 1 in the list and add the sum of the two numbers at the end of the list one by one.
While loop is used so that the added number does not exceed the upper bound | cs1qa | null | null | null | null | null | Question:
I'll explain task 1!
Code:
def fibonacci(upper_bound):
l=[0,1]
while (l[len(l)-2]+l[len(l)-1])<upper_bound:
l.append(l[len(l)-2]+l[len(l)-1])
return l
print(fibonacci(1000))
|
4 | 2 | TA | Please explain along with the process which constants of the math module were used in Task3~ | import math
sin = math.sin
pi = math.pi
a=int(input('How many steps?: '))
for i in range(a):
x = float(i) / 30.0 * 2 * pi
print (sin(x)) | 2 | 3 | code_explain | We only used sin and pi in the math module, of which the constant pi was used to calculate x! | cs1qa | null | null | null | null | null | Question:
Please explain along with the process which constants of the math module were used in Task3~
Code:
import math
sin = math.sin
pi = math.pi
a=int(input('How many steps?: '))
for i in range(a):
x = float(i) / 30.0 * 2 * pi
print (sin(x)) |
5 | 0 | TA | What is the pick_up() function in task1? | from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot()
hubo.set_trace('blue')
def hubo_turn_right():
for i in range(3):
hubo.turn_left()
def pick_up():
for i in range(5):
hubo.move()
if hubo.on_beeper():
hubo.pick_beeper()
def turn1():
hubo.turn_left(... | 9 | 13 | variable | This is a function that picks up the beeper if the robot goes forward and is on the beeper. | cs1qa | null | null | null | null | null | Question:
What is the pick_up() function in task1?
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot()
hubo.set_trace('blue')
def hubo_turn_right():
for i in range(3):
hubo.turn_left()
def pick_up():
for i in range(5):
hubo.move()
if hubo.on_beeper():
... |
8 | 0 | TA | Then, please explain the algorithm you wrote in Task 1! | import elice_utils
from time import sleep
def merge(input_filenames, output_filename):
merge_result = open('output.txt', 'a')
for i in range(len(input_filenames)):
merge = open(input_filenames[i], 'r')
for line in merge:
data = line
merge_result.write(data)
pass
mer... | 4 | 9 | code_explain | At number one, the input comes into the list
Read each list through iteration
After reading this for each line through the open function
I wrote it in the output | cs1qa | null | null | null | null | null | Question:
Then, please explain the algorithm you wrote in Task 1!
Code:
import elice_utils
from time import sleep
def merge(input_filenames, output_filename):
merge_result = open('output.txt', 'a')
for i in range(len(input_filenames)):
merge = open(input_filenames[i], 'r')
for line in merge:... |
2 | 1 | TA | What is plant() in task2? | from cs1robots import *
load_world('worlds/harvest3.wld')
hubo=Robot(beepers=6)
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def plant():
hubo.move()
if not hubo.on_beeper():
hubo.drop_beeper()
def curve():
for i in range(5):
plant()
hubo.turn_... | 7 | 10 | variable | If there is no beeper moving and there is no beeper, this is the dropping function to plant the beeper | cs1qa | null | null | null | null | null | Question:
What is plant() in task2?
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
hubo=Robot(beepers=6)
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def plant():
hubo.move()
if not hubo.on_beeper():
hubo.drop_beeper()
def curve():
for ... |
8 | 0 | TA | Please briefly explain what the meaning of "r" and "w" used to open! | from time import sleep
import elice_utils
def merge(input_filenames, output_filename):
# Implement here
# ...
file1=open(output_filename,"w")
for file_names in input_filenames:
file2=open(file_names,"r")
for line in file2:
file1.write(line)
file2.close()
file1.cl... | 6 | 8 | variable | 'r' means open for reading (default),'w' means open for writing, truncating the file first. | cs1qa | null | null | null | null | null | Question:
Please briefly explain what the meaning of "r" and "w" used to open!
Code:
from time import sleep
import elice_utils
def merge(input_filenames, output_filename):
# Implement here
# ...
file1=open(output_filename,"w")
for file_names in input_filenames:
file2=open(file_names,"r")
... |
3 | 4 | TA | How did you do the color classification in task5, and where is the code that makes it blue when dark? | from cs1media import *
# This code converts an image into a black & white poster.
white = (255, 255, 255)
black = (0, 0, 0)
yellow = (255, 255, 0)
blue = (0, 0, 255)
green = (0, 255, 0)
image = load_picture('./images/minion.jpg')
width, height = image.size()
for y in range(height):
for x in range(width):
... | 17 | 22 | code_explain | The average_brightness value is divided by 150 and 70, and lines 20 and 21 are blue. | cs1qa | null | null | null | null | null | Question:
How did you do the color classification in task5, and where is the code that makes it blue when dark?
Code:
from cs1media import *
# This code converts an image into a black & white poster.
white = (255, 255, 255)
black = (0, 0, 0)
yellow = (255, 255, 0)
blue = (0, 0, 255)
green = (0, 255, 0)
image = lo... |
4 | 1 | TA | Why do I need to process float() after receiving input from Task 2? |
def is_triangle(a, b, c):
return ("YES" if (a < b + c) and (b < a + c) and (c < a + b) else "NO")
a = float(input('Side a: '))
b = float(input('Side b: '))
c = float(input('Side c: '))
print(is_triangle(a,b,c)) | 4 | 6 | reasoning | Since all the contents obtained from the input function are treated as strings, we changed the data type! | cs1qa | null | null | null | null | null | Question:
Why do I need to process float() after receiving input from Task 2?
Code:
def is_triangle(a, b, c):
return ("YES" if (a < b + c) and (b < a + c) and (c < a + b) else "NO")
a = float(input('Side a: '))
b = float(input('Side b: '))
c = float(input('Side c: '))
print(is_triangle(a,b,c)) |
1 | 2 | TA | Please briefly explain what functions up_stair, down_stair, and drop_and_turn are and how they work. | from cs1robots import *
load_world('worlds/newspaper.wld')
hubo = Robot(beepers = 1)
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def up_stair():
while hubo.front_is_clear():
hubo.move()
hubo.turn_left()
hubo.move()
turn_right()
def drop_and_turn():
... | 7 | 22 | variable | up_stair and down_stair are the functions you need to go up and down the stairs respectively, go up to the front of the stairs, then use turn to go up and down stairs | cs1qa | null | null | null | null | null | Question:
Please briefly explain what functions up_stair, down_stair, and drop_and_turn are and how they work.
Code:
from cs1robots import *
load_world('worlds/newspaper.wld')
hubo = Robot(beepers = 1)
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def up_stair():
while ... |
6 | 1 | TA | l = []
for i in range(n):
l.append(i)
What is the reason why l = range(n) without this | import random
def drawing_integers(lb, ub, trials):
"""
Make a list of the integers
:param lb: the lower bound of the integers
:param ub: the upper bound of the integers
:param trials: the number of trials
:return: an integers list. Ex) [1, 4, 3, 5, 2]
"""
list = []
for i in range(i... | null | null | reasoning | I think it’s because range(n) is a list | cs1qa | null | null | null | null | null | Question:
l = []
for i in range(n):
l.append(i)
What is the reason why l = range(n) without this
Code:
import random
def drawing_integers(lb, ub, trials):
"""
Make a list of the integers
:param lb: the lower bound of the integers
:param ub: the upper bound of the integers
:param trials: the... |
1 | 1 | TA | What is pick_beeper() in task2? | from cs1robots import *
load_world("worlds/hurdles1.wld")
R1 = Robot()
R1.set_trace("blue")
def turn_right():
for i in range(3):
R1.turn_left()
for i in range(4):
R1.move()
R1.turn_left()
R1.move()
turn_right()
R1.move()
turn_right()
R1.move()
R1.turn_left()
R1.move()
R1.pick... | 17 | 17 | variable | This is a function that the robot (R1) picks up a yellow coin with 1 written on it. | cs1qa | null | null | null | null | null | Question:
What is pick_beeper() in task2?
Code:
from cs1robots import *
load_world("worlds/hurdles1.wld")
R1 = Robot()
R1.set_trace("blue")
def turn_right():
for i in range(3):
R1.turn_left()
for i in range(4):
R1.move()
R1.turn_left()
R1.move()
turn_right()
R1.move()
turn_right()... |
5 | 0 | TA | Why should I use global balance in task1? | balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
# Do something on here !
global balance
balance = ... | 0 | 37 | reasoning | I used it because I had to change the value of the balance (because I have to use it, not just read it)! | cs1qa | null | null | null | null | null | Question:
Why should I use global balance in task1?
Code:
balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
... |
3 | 3 | TA | In task4, did you use x to check if you came to the original position?? | from cs1robots import *
load_world('worlds/rain2.wld')
hubo = Robot(beepers=100, avenue=2, street=6, orientation='E')
hubo.set_trace('blue')
x=0
def check():
global x
if hubo.on_beeper():
x=x+1
def turn_right():
for i in range(3):
hubo.turn_left()
def turn_around():
f... | 52 | 54 | variable | I made sure we're back to the starting position | cs1qa | null | null | null | null | null | Question:
In task4, did you use x to check if you came to the original position??
Code:
from cs1robots import *
load_world('worlds/rain2.wld')
hubo = Robot(beepers=100, avenue=2, street=6, orientation='E')
hubo.set_trace('blue')
x=0
def check():
global x
if hubo.on_beeper():
x=x+1
def turn... |
1 | 1 | TA | What is pick_beeper() in task2? | from cs1robots import *
load_world("worlds/hurdles1.wld")
R1 = Robot()
R1.set_trace("blue")
def turn_right():
for i in range(3):
R1.turn_left()
for i in range(4):
R1.move()
R1.turn_left()
R1.move()
turn_right()
R1.move()
turn_right()
R1.move()
R1.turn_left()
R1.move()
R1.pick... | 17 | 17 | variable | This is a function that the robot (R1) picks up a yellow coin with 1 written on it. | cs1qa | null | null | null | null | null | Question:
What is pick_beeper() in task2?
Code:
from cs1robots import *
load_world("worlds/hurdles1.wld")
R1 = Robot()
R1.set_trace("blue")
def turn_right():
for i in range(3):
R1.turn_left()
for i in range(4):
R1.move()
R1.turn_left()
R1.move()
turn_right()
R1.move()
turn_right()... |
1 | 4 | TA | The last thing you did without diagonal_bottom() is because of the conflict? | from cs1robots import*
load_world('worlds/harvest2.wld')
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
hubo.turn_left()
hubo.turn_left()
hubo.turn_left()
for i in range(4):
hubo.move()
def diagonal_top():
for i in range(6):
hubo.move()
hubo.turn_left()
hubo.move()
... | 33 | 44 | reasoning | Yeah | cs1qa | null | null | null | null | null | Question:
The last thing you did without diagonal_bottom() is because of the conflict?
Code:
from cs1robots import*
load_world('worlds/harvest2.wld')
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
hubo.turn_left()
hubo.turn_left()
hubo.turn_left()
for i in range(4):
hubo.move()
def diagonal_to... |
4 | 0 | TA | Briefly explain the name and action of the function you add in Task1! | from cs1robots import *
load_world('worlds/add34.wld')
my_robot = Robot()
'''
Abstract, Final, Static class "Logic".
Contains useful logics, which are frequently used.
Since I started programming with Java, "global functions" do not look
so good for me :D
'''
class Logic:
@staticmethod
def rpt(fu, i, ar... | 124 | 131 | variable | solve_assignment.
It repeats add_digit that adds the number of digits to the currently standing column, and performs retrieval and map end processing. | cs1qa | null | null | null | null | null | Question:
Briefly explain the name and action of the function you add in Task1!
Code:
from cs1robots import *
load_world('worlds/add34.wld')
my_robot = Robot()
'''
Abstract, Final, Static class "Logic".
Contains useful logics, which are frequently used.
Since I started programming with Java, "global functions" do... |
9 | 0 | TA | Can you explain reverse_cards first? | from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
check_num=0
class Card(object):
def personalit... | 45 | 58 | variable | reverse_cards is a function that shows cards shuffled randomly over the first 4 seconds. | cs1qa | null | null | null | null | null | Question:
Can you explain reverse_cards first?
Code:
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries... |
4 | 2 | TA | Please explain task3 as well | import math
sin = math.sin
pi = math.pi
a=input('How many steps? ')
for i in range(int(a)):
x = float(i) / 30.0 * 2 * pi
print (sin(x)) | 5 | 8 | code_explain | task3 receives a number into the variable a and increases the given x value constant during a loop to output the sine value. | cs1qa | null | null | null | null | null | Question:
Please explain task3 as well
Code:
import math
sin = math.sin
pi = math.pi
a=input('How many steps? ')
for i in range(int(a)):
x = float(i) / 30.0 * 2 * pi
print (sin(x)) |
2 | 0 | TA | Please explain from task1! | from cs1robots import*
load_world('worlds/harvest3.wld')
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def harvest_a_carrot():
hubo.move()
if hubo.on_beeper():
hubo.pick_beeper()
def harvest_odd_line():
harvest_a_carrot()
hubo.turn_left()
... | 7 | 27 | code_explain | task1 uses the if statement to think about the case where there is no carrot in the existing task.
The picking function has been changed so that only carrots are picked up. | cs1qa | null | null | null | null | null | Question:
Please explain from task1!
Code:
from cs1robots import*
load_world('worlds/harvest3.wld')
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def harvest_a_carrot():
hubo.move()
if hubo.on_beeper():
hubo.pick_beeper()
def harvest_odd_line()... |
1 | 1 | TA | Can you explain what function pattern() is in task2? | from cs1robots import*
load_world('worlds/hurdles1.wld')
hubo=Robot()
hubo.set_trace('red')
def pattern():
hubo.move()
hubo.turn_left()
hubo.move()
for i in range(3):
hubo.turn_left()
hubo.move()
for i in range(3):
hubo.turn_left()
hubo.move()
hubo.turn_left()
for i i... | 7 | 17 | variable | In task2, pattern() just specified a function to skip one hurdle like that. | cs1qa | null | null | null | null | null | Question:
Can you explain what function pattern() is in task2?
Code:
from cs1robots import*
load_world('worlds/hurdles1.wld')
hubo=Robot()
hubo.set_trace('red')
def pattern():
hubo.move()
hubo.turn_left()
hubo.move()
for i in range(3):
hubo.turn_left()
hubo.move()
for i in range(3)... |
8 | 1 | TA | Why did you use a strip on lines 18-19 in the second task? | f=open("average-latitude-longitude-countries.csv", 'r')
for line in f:
word=line.strip()
print(word)
f.close()
f=open("average-latitude-longitude-countries.csv", 'r')
a=[]
b=[]
f.readline()
for line in f:
word=line.strip()
p=word.split(',')
if len(p)>4:
while len(p)>4:
name=p.po... | 10 | 22 | reasoning | When printed, the country code and country name are displayed in the form of a double quotation mark in a small quotation mark in the list (such as'"code"'), so I used a strip to remove the large quotation marks. | cs1qa | null | null | null | null | null | Question:
Why did you use a strip on lines 18-19 in the second task?
Code:
f=open("average-latitude-longitude-countries.csv", 'r')
for line in f:
word=line.strip()
print(word)
f.close()
f=open("average-latitude-longitude-countries.csv", 'r')
a=[]
b=[]
f.readline()
for line in f:
word=line.strip()
p=... |
9 | 0 | TA | What information does an object of class Card in task2 have? | from cs1graphics import *
import time
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct = 0
class Card:
def __init__(self, img, name):
... | 14 | 18 | variable | Has the card image, shape, number, value of the card, and whether the card is hidden | cs1qa | null | null | null | null | null | Question:
What information does an object of class Card in task2 have?
Code:
from cs1graphics import *
import time
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads ... |
5 | 0 | TA | can you briefly explain task1 withdrawal function?? | balance = 0
def deposit(money) :
global balance
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
balance=balance+money
print("You deposited {} won".format(money))
# Do something on here !
... | 16 | 29 | variable | withdrawal is a function that subtracts by the number you entered, but issues a warning when the subtraction number is larger. | cs1qa | null | null | null | null | null | Question:
can you briefly explain task1 withdrawal function??
Code:
balance = 0
def deposit(money) :
global balance
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
balance=balance+money
pri... |
2 | 0 | TA | Could you briefly explain what the move_and_pick function does? | from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot()
hubo.set_trace('blue')
def move_and_pick() :
hubo.move()
if hubo.on_beeper() :
hubo.pick_beeper()
def turn_right():
hubo.turn_left()
hubo.turn_left()
hubo.turn_left()
for i in range (2):
while hubo.front_... | 5 | 8 | variable | It is a function that moves one space and picks up if there is a beeper in the moved position. | cs1qa | null | null | null | null | null | Question:
Could you briefly explain what the move_and_pick function does?
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot()
hubo.set_trace('blue')
def move_and_pick() :
hubo.move()
if hubo.on_beeper() :
hubo.pick_beeper()
def turn_right():
hubo.turn_left()
... |
3 | 1 | TA | Is there any special reason for writing the while statement in Task2 line13? | from cs1robots import *
# Your code must work for all world files below.
#load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
my_robot = Robot()
def turn_right():
for i in range(3):
my_robot.turn_left()
number_beeper=0
while my_robot.carries_beepers:
while my_robot.on_beeper():
... | 12 | 18 | reasoning | I used it to keep the inner loops repeatable while the robot moves the beeper. | cs1qa | null | null | null | null | null | Question:
Is there any special reason for writing the while statement in Task2 line13?
Code:
from cs1robots import *
# Your code must work for all world files below.
#load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
my_robot = Robot()
def turn_right():
for i in range(3):
my_robot.tur... |
8 | 0 | TA | What is the f.read() function in task1? | from time import sleep
import elice_utils
def merge(input_filenames, output_filename):
temp_list = []
for name in input_filenames:
fin = open(name, 'rt')
temp_list.append(fin.read())
fin.close()
fout = open(output_filename, 'xt')
fout.write(''.join(temp_list))
fout... | 7 | 8 | variable | This function reads all the text in the file. | cs1qa | null | null | null | null | null | Question:
What is the f.read() function in task1?
Code:
from time import sleep
import elice_utils
def merge(input_filenames, output_filename):
temp_list = []
for name in input_filenames:
fin = open(name, 'rt')
temp_list.append(fin.read())
fin.close()
fout = open(output_... |
5 | 0 | TA | How did you use the balance variable in Task1? | balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
global balance
balance+=money
#################
### implement ###
#################
# Do something on here !
... | 0 | 33 | variable | The balance variable was used as a variable representing the total money and used as a global variable so that the amount changed in the function was applied to the entire program. | cs1qa | null | null | null | null | null | Question:
How did you use the balance variable in Task1?
Code:
balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
global balance
balance+=money
#################
###... |
8 | 0 | TA | Please explain the ‘r’ and ‘w’ variables of open(). | from time import sleep
import elice_utils
def merge(input_filenames, output_filename):
d = open(output_filename , 'w')
a = len(input_filenames)
for i in range(a):
c = input_filenames[i]
f = open(c, 'r')
b = f.readlines()
for x in range(len(b)):
d.write(b[x])
... | 4 | 8 | variable | r is used to read files and w is used to write files. | cs1qa | null | null | null | null | null | Question:
Please explain the ‘r’ and ‘w’ variables of open().
Code:
from time import sleep
import elice_utils
def merge(input_filenames, output_filename):
d = open(output_filename , 'w')
a = len(input_filenames)
for i in range(a):
c = input_filenames[i]
f = open(c, 'r')
b = f.rea... |
3 | 4 | TA | in task5
image.set(x, y, yellow)
Mean? | from cs1media import *
# This code converts an image into a black & white poster.
threshold1 = 100
threshold2 = 200
white = (255, 255, 255)
black = (0, 0, 0)
yellow = (255, 255, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
image = load_picture('./images/minion.jpg')
width, height = image.size()
for y in range(height):... | 20 | 20 | variable | The pixel color of the x and y coordinates is set to yellow as defined above. | cs1qa | null | null | null | null | null | Question:
in task5
image.set(x, y, yellow)
Mean?
Code:
from cs1media import *
# This code converts an image into a black & white poster.
threshold1 = 100
threshold2 = 200
white = (255, 255, 255)
black = (0, 0, 0)
yellow = (255, 255, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
image = load_picture('./images/minion.j... |
2 | 2 | TA | Could you please tell me why I set the conditions this way? | from cs1robots import *
load_world('worlds/hurdles3.wld')
hubo= Robot(beepers=100)
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def jump_one_hurdle():
hubo.turn_left()
hubo.move()
turn_right()
hubo.move()
turn_right()
... | 18 | 22 | reasoning | The second task condition told me to stop if you step on the beeper.
If you step on the beeper, the conditions below will not work.
Before stepping on the beeper, the lower door will run and move over the hurdles | cs1qa | null | null | null | null | null | Question:
Could you please tell me why I set the conditions this way?
Code:
from cs1robots import *
load_world('worlds/hurdles3.wld')
hubo= Robot(beepers=100)
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def jump_one_hurdle():
hubo.turn_left()
hu... |
1 | 2 | TA | Is there a reason for defining jump_up() and jump_down() separately in stair_up() and stair_down()? | from cs1robots import *
load_world("worlds/newspaper.wld")
hubo = Robot(beepers=1)
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def jump_up():
hubo.turn_left()
hubo.move()
turn_right()
hubo.move()
def stair_up():
for i in range (4):
jump_up... | 9 | 26 | reasoning | I have defined it separately to clearly indicate going up and going down. | cs1qa | null | null | null | null | null | Question:
Is there a reason for defining jump_up() and jump_down() separately in stair_up() and stair_down()?
Code:
from cs1robots import *
load_world("worlds/newspaper.wld")
hubo = Robot(beepers=1)
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def jump_up():
hubo.tu... |
6 | 4 | TA | Please explain your last task! | from cs1robots import *
# create_world()
# load_world('worlds/world_file_name.wld')
load_world('worlds/harvest2.wld')
hubo = Robot()
def turn_right():
for i in range(3):
hubo.turn_left()
def diagonal():
hubo.pick_beeper()
hubo.move()
hubo.turn_left()
hubo.move()
turn_right()
for i i... | 18 | 50 | code_explain | This is done in a zigzag diagonal direction.
The diagonal function consists of moving-left-going-right rotation while looking up.
Diagonal lines going up left and down right have different viewing directions, but the process of action is the same.
So, only the point where the direction changes is entered separately and... | cs1qa | null | null | null | null | null | Question:
Please explain your last task!
Code:
from cs1robots import *
# create_world()
# load_world('worlds/world_file_name.wld')
load_world('worlds/harvest2.wld')
hubo = Robot()
def turn_right():
for i in range(3):
hubo.turn_left()
def diagonal():
hubo.pick_beeper()
hubo.move()
hubo.turn... |
2 | 0 | TA | Is there a reason for dividing move1 and move2 in task1? | from cs1robots import *
load_world("worlds/harvest3.wld")
hubo = Robot()
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def move_and_pick():
hubo.move()
if hubo.on_beeper():
hubo.pick_beeper()
def move1():
for i in range(5):
move_and_pick()
hubo.... | 11 | 22 | reasoning | Because I tried to separate the two cases of turning left and turning right | cs1qa | null | null | null | null | null | Question:
Is there a reason for dividing move1 and move2 in task1?
Code:
from cs1robots import *
load_world("worlds/harvest3.wld")
hubo = Robot()
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def move_and_pick():
hubo.move()
if hubo.on_beeper():
hubo.pick_be... |
8 | 1 | TA | Why is there an input("press again") in that animation? | from cs1graphics import *
from time import sleep
canvas = Canvas(800, 600)
canvas.setBackgroundColor("light blue")
canvas.setTitle("Zoo")
ground = Rectangle(800, 250, Point(400, 475))
ground.setFillColor((0, 255, 0))
ground.setDepth(100)
ground.setBorderWidth(5)
ground.setBorderColor((0, 255, 0))
canvas.add(ground)
e... | 154 | 154 | reasoning | I will fix it | cs1qa | null | null | null | null | null | Question:
Why is there an input("press again") in that animation?
Code:
from cs1graphics import *
from time import sleep
canvas = Canvas(800, 600)
canvas.setBackgroundColor("light blue")
canvas.setTitle("Zoo")
ground = Rectangle(800, 250, Point(400, 475))
ground.setFillColor((0, 255, 0))
ground.setDepth(100)
ground... |
6 | 2 | student | But I'm not sure about the fundamental reason why you need to repeat the code below as many times as the number of cards using a for statement. | from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct_list = []
def initialize():
# initial... | 16 | 30 | code_understanding | Yes, as the student said, this is a very inefficient code! | cs1qa | null | null | null | null | null | Question:
But I'm not sure about the fundamental reason why you need to repeat the code below as many times as the number of cards using a for statement.
Code:
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin... |
3 | 4 | TA | task 5 Something is quite yellow. Why is the value set? | from cs1media import *
# This code converts an image into a black & white poster.
threshold = 100
yellow = (255, 255, 0)
blue = (0, 0, 255)
green = (0,255,0)
image = load_picture('./images/minion.jpg')
width, height = image.size()
for y in range(height):
for x in range(width):
r, g, b = image.get(x, y)
... | 16 | 21 | reasoning | The task 5 value was just set to look moderately green, because there is no specific standard. | cs1qa | null | null | null | null | null | Question:
task 5 Something is quite yellow. Why is the value set?
Code:
from cs1media import *
# This code converts an image into a black & white poster.
threshold = 100
yellow = (255, 255, 0)
blue = (0, 0, 255)
green = (0,255,0)
image = load_picture('./images/minion.jpg')
width, height = image.size()
for y in r... |
9 | 0 | student | In Task 1, it was written even though I didn't enter .jpg. Why? | from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
class Card(object):
def __init__(self, img, na... | 8 | 9 | code_understanding | Each element in the names list contains the string ".jpg". | cs1qa | null | null | null | null | null | Question:
In Task 1, it was written even though I didn't enter .jpg. Why?
Code:
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
car... |
3 | 0 | TA | Why is line 7 in task1? | from cs1robots import *
create_world()
robot = Robot(orientation='W', avenue=4, street=4)
robot.set_trace("red")
def initial_position():
while robot.facing_north() is True:
robot.turn_left()
while robot.front_is_clear():
robot.move()
robot.turn_left()
while robot.front_i... | 6 | 6 | reasoning | At first, it was written in the sense of running the code below when the robot faces north, but it doesn't seem necessary. | cs1qa | null | null | null | null | null | Question:
Why is line 7 in task1?
Code:
from cs1robots import *
create_world()
robot = Robot(orientation='W', avenue=4, street=4)
robot.set_trace("red")
def initial_position():
while robot.facing_north() is True:
robot.turn_left()
while robot.front_is_clear():
robot.move()
ro... |
2 | 2 | TA | Please explain each function in Task3 Hurdle | from cs1robots import *
# Your code should work with any of the world files below.
# TIP: Press Ctrl + '/' (or Cmd + '/' if you are using a Mac)
# to comment out or restore the whole line of the code in the editor.
#load_world('worlds/hurdles1.wld')
#load_world('worlds/hurdles2.wld')
load_world('worlds/hurdles3.wl... | 14 | 32 | variable | I made a function that rotates to the right, and after making more than one hurdle, when it reaches the beeper, it stops and picks up the beeper. | cs1qa | null | null | null | null | null | Question:
Please explain each function in Task3 Hurdle
Code:
from cs1robots import *
# Your code should work with any of the world files below.
# TIP: Press Ctrl + '/' (or Cmd + '/' if you are using a Mac)
# to comment out or restore the whole line of the code in the editor.
#load_world('worlds/hurdles1.wld')
#... |
4 | 0 | TA | Can you explain task 1 algorithm? | from cs1robots import *
load_world( "worlds/add2.wld" )
hubo=Robot(beepers=100)
hubo.set_trace('blue')
first=[]
second=[]
for x in range(5):
hubo.move()
for x in range(4):
hubo.move()
n=0
while hubo.on_beeper():
hubo.pick_beeper()
n+=1
first.append(n)
hubo.turn_left()
hubo.move(... | 0 | 55 | code_explain | Task 1 is implemented by receiving two lines in the form of a list, calculating the sum of each component from each list in the form of a list, and then rounding up if it exceeds 10. | cs1qa | null | null | null | null | null | Question:
Can you explain task 1 algorithm?
Code:
from cs1robots import *
load_world( "worlds/add2.wld" )
hubo=Robot(beepers=100)
hubo.set_trace('blue')
first=[]
second=[]
for x in range(5):
hubo.move()
for x in range(4):
hubo.move()
n=0
while hubo.on_beeper():
hubo.pick_beeper()
... |
3 | 1 | TA | For task 2, why do you have both line 18-19 and line 21-22? | from cs1robots import *
# Your code must work for all world files below.
# load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def uturn():
for i in range(2):
turn_right()
while hubo.fro... | 17 | 21 | reasoning | Just to pick all the beepers and the reason that line 21-22 exists is that we have to make sure that the robot still pick the beeper(s) at the point which front is not clear too | cs1qa | null | null | null | null | null | Question:
For task 2, why do you have both line 18-19 and line 21-22?
Code:
from cs1robots import *
# Your code must work for all world files below.
# load_world( "worlds/trash1.wld" )
load_world( "worlds/trash2.wld" )
hubo=Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_... |
9 | 2 | student | What does valid range mean in is_valid function | from cs1graphics import *
import time
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct_list = []
def initialize():
# initialize cards
... | 59 | 68 | code_understanding | Refers to 0-23 | cs1qa | null | null | null | null | null | Question:
What does valid range mean in is_valid function
Code:
from cs1graphics import *
import time
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = ... |
4 | 2 | TA | Please explain along with the process which constants of the math module were used in Task3~ | import math
sin = math.sin
pi = math.pi
a=int(input('How many steps?: '))
for i in range(a):
x = float(i) / 30.0 * 2 * pi
print (sin(x)) | 2 | 9 | code_explain | We only used sin and pi in the math module, of which the constant pi was used to calculate x! | cs1qa | null | null | null | null | null | Question:
Please explain along with the process which constants of the math module were used in Task3~
Code:
import math
sin = math.sin
pi = math.pi
a=int(input('How many steps?: '))
for i in range(a):
x = float(i) / 30.0 * 2 * pi
print (sin(x)) |
1 | 2 | TA | Is there a reason for defining jump_up() and jump_down() separately in stair_up() and stair_down()? | from cs1robots import *
load_world("worlds/newspaper.wld")
hubo = Robot(beepers=1)
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def jump_up():
hubo.turn_left()
hubo.move()
turn_right()
hubo.move()
def stair_up():
for i in range (4):
jump_up... | 9 | 27 | reasoning | I have defined it separately to clearly indicate going up and going down. | cs1qa | null | null | null | null | null | Question:
Is there a reason for defining jump_up() and jump_down() separately in stair_up() and stair_down()?
Code:
from cs1robots import *
load_world("worlds/newspaper.wld")
hubo = Robot(beepers=1)
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def jump_up():
hubo.tu... |
4 | 1 | TA | In No. 2, a part that applies the float function, such as a = float (a), comes out. Please explain why you need this code! |
def is_triangle(a, b, c):
if a+b>c and b+c>a and c+a>b:
return True
else:
return False
a = input('Side a: ')
print('Value of a is', a)
a = float (a)
b = input('Side b: ')
print('Value of b is', b)
b = float (b)
c = input('Side c: ')
print('Value of c is', c)
c = float (c)
is_triangle(a,b,c)... | 7 | 9 | reasoning | Because the value received as an input is a string, you need to convert the value into a float to calculate it as a number! | cs1qa | null | null | null | null | null | Question:
In No. 2, a part that applies the float function, such as a = float (a), comes out. Please explain why you need this code!
Code:
def is_triangle(a, b, c):
if a+b>c and b+c>a and c+a>b:
return True
else:
return False
a = input('Side a: ')
print('Value of a is', a)
a = float (a)
b ... |
9 | 1 | TA | What information does an object of class Card in task2 have? | import random
from cs1graphics import *
img_path = './images/'
suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
face_names = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
value = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
bj_board = Canvas(600, 400, 'dark green', 'Black Jac... | 17 | 23 | variable | Suit, face, value, image file path, front and back information | cs1qa | null | null | null | null | null | Question:
What information does an object of class Card in task2 have?
Code:
import random
from cs1graphics import *
img_path = './images/'
suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
face_names = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
value = [11, 2, 3, 4, 5, 6, ... |
1 | 0 | TA | Can you see what the root1 function does? | from cs1robots import *
create_world()
hubo = Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def root1():
hubo.turn_left()
for i in range(9):
hubo.move()
turn_right()
hubo.move()
turn_right()
for i in range(9):
hubo.move()
for... | 10 | 18 | variable | Zigzag up and down repeatedly
I made it as a function | cs1qa | null | null | null | null | null | Question:
Can you see what the root1 function does?
Code:
from cs1robots import *
create_world()
hubo = Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def root1():
hubo.turn_left()
for i in range(9):
hubo.move()
turn_right()
hubo.move()
... |
4 | 4 | TA | Is there any reason you split the range in half? | import math
sin = math.sin
pi = math.pi
for i in range(21) :
x = float(i) / 40.0 * 2 * pi
character_count_per_line = 3+int((sin(x)+1)*40)
output_str = " "* character_count_per_line
print (output_str, ".")
for i in range(21) :
x = float(i) / 40.0 * 2 * pi
character_count_per_line =80-i... | 5 | 17 | reasoning | Come to think of it, there was no reason to split it up... sorry | cs1qa | null | null | null | null | null | Question:
Is there any reason you split the range in half?
Code:
import math
sin = math.sin
pi = math.pi
for i in range(21) :
x = float(i) / 40.0 * 2 * pi
character_count_per_line = 3+int((sin(x)+1)*40)
output_str = " "* character_count_per_line
print (output_str, ".")
for i in range(21) :
... |
1 | 2 | TA | At number 3
hubo.move()
time.sleep(0.2)
hubo.drop_beeper()
time.sleep(0.2)
hubo.turn_left()
time.sleep(0.2)
hubo.turn_left()
time.sleep(0.2)
Can you explain what this part does? | from cs1robots import *
load_world('worlds/newspaper.wld')
import time
hubo=Robot(beepers=1)
hubo.set_trace('blue')
def turn_right():
for i in range (3):
hubo.turn_left()
time.sleep(0.2)
def go_up_stair():
hubo.turn_left()
time.sleep(0.2)
hubo.move()
time.sleep(0.2)
turn_right()
hubo.move()
time.sleep(0... | 35 | 42 | code_explain | This is the process of the robot turning around after delivering the newspaper.
Since it is used only once, no function is specified. | cs1qa | null | null | null | null | null | Question:
At number 3
hubo.move()
time.sleep(0.2)
hubo.drop_beeper()
time.sleep(0.2)
hubo.turn_left()
time.sleep(0.2)
hubo.turn_left()
time.sleep(0.2)
Can you explain what this part does?
Code:
from cs1robots import *
load_world('worlds/newspaper.wld')
import time
hubo=Robot(beepers=1)
hubo.set_trace('blue')
def ... |
6 | 2 | student | But what is 3-2-2 next to # on line 45?? | from cs1graphics import *
import time
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct_list = []
def initialize():
# initialize cards
... | 44 | 44 | code_understanding | It is a story to fix the condition of the string
It's just a comment | cs1qa | null | null | null | null | null | Question:
But what is 3-2-2 next to # on line 45??
Code:
from cs1graphics import *
import time
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
corre... |
3 | 3 | TA | Please explain how you wrote the code for the protruding part in the middle of the rain2 world! | from cs1robots import *
# Your code must work for both of the worlds below.
# load_world('worlds/rain1.wld')
load_world('worlds/rain2.wld')
# Initialize your robot at the door of the house.
my_robot = Robot(beepers=100, avenue=2, street=6, orientation='E')
my_robot.set_trace("blue")
def turn_right():
for i in range... | 38 | 42 | code_explain | If there is a protruding part in the middle, the cord is squeezed so that only that part is properly passed. | cs1qa | null | null | null | null | null | Question:
Please explain how you wrote the code for the protruding part in the middle of the rain2 world!
Code:
from cs1robots import *
# Your code must work for both of the worlds below.
# load_world('worlds/rain1.wld')
load_world('worlds/rain2.wld')
# Initialize your robot at the door of the house.
my_robot = Ro... |
5 | 0 | TA | What method did you use to change the balance amount in the deposit and withdrawal functions? | balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
# Do something on here !
global balance
balance = ... | 0 | 35 | code_explain | We used global to change the value of the global variable balance in a function, and add or take away the balance according to the function by setting the parameter money in each function. | cs1qa | null | null | null | null | null | Question:
What method did you use to change the balance amount in the deposit and withdrawal functions?
Code:
balance = 0
def deposit(money) :
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
###########... |
2 | 0 | TA | Please explain what the flag is for Tasks 1 and 2. | from cs1robots import *
load_world('worlds/harvest3.wld')
def move(n=1):
for i in range(n):
h.move()
def left():
h.turn_left()
def right():
for i in range(3):
left()
h = Robot(beepers=36)
h.set_trace('blue')
move()
def oneStep():
if h.on_beeper():
h.pick_beeper()
move()
de... | 20 | 32 | variable | Yes, in 1,2, the flag is a variable indicating whether the current line is an even number or an odd number, and is used to determine whether the current line ends and rotates left or right. | cs1qa | null | null | null | null | null | Question:
Please explain what the flag is for Tasks 1 and 2.
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
def move(n=1):
for i in range(n):
h.move()
def left():
h.turn_left()
def right():
for i in range(3):
left()
h = Robot(beepers=36)
h.set_trace('blue')
move()
def o... |
5 | 1 | TA | I set variables such as car and canvas to global. Is there any reason? | from cs1graphics import *
from time import sleep
canvas = Canvas(600,200)
canvas.setBackgroundColor("light blue")
car = Layer()
gas = Circle(1)
gas.setFillColor("white")
gas.moveTo(45,135)
canvas.add(gas)
def draw_animal():
# Implement this function.
global car
global canvas
tire1 = Circle(10, Po... | 34 | 35 | reasoning | Isn't it necessary to use global to get and use a global variable in a function?
Is it not necessary to modify the variable value? | cs1qa | null | null | null | null | null | Question:
I set variables such as car and canvas to global. Is there any reason?
Code:
from cs1graphics import *
from time import sleep
canvas = Canvas(600,200)
canvas.setBackgroundColor("light blue")
car = Layer()
gas = Circle(1)
gas.setFillColor("white")
gas.moveTo(45,135)
canvas.add(gas)
def draw_animal():
... |
2 | 0 | TA | Please briefly explain how to pick up the beeper in step 1 along with the function name! | from cs1robots import *
load_world("worlds/harvest3.wld")
hubo = Robot()
hubo.set_trace('blue')
hubo.move()
def turn_right():
for i in range(3):
hubo.turn_left()
def goStraight():
for i in range(5):
if hubo.on_beeper():
hubo.pick_beeper()
hubo.move()
def turnAroundLeft():... | 11 | 33 | code_explain | First, in the straight section, the goStraight() function was used to pick up the beeper, and turnAroundRight() and turnAroundLeft() were used when turning to the right and turning to the left, respectively. | cs1qa | null | null | null | null | null | Question:
Please briefly explain how to pick up the beeper in step 1 along with the function name!
Code:
from cs1robots import *
load_world("worlds/harvest3.wld")
hubo = Robot()
hubo.set_trace('blue')
hubo.move()
def turn_right():
for i in range(3):
hubo.turn_left()
def goStraight():
for i in rang... |
9 | 0 | TA | Why is the while statement termination condition if n==25:? | # Copy your "Memento" code from the task in Lab 6.
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1... | 100 | 124 | reasoning | When n is the number of cards with state=True, when n becomes 25, it means that all 24 cards are turned upside down. | cs1qa | null | null | null | null | null | Question:
Why is the while statement termination condition if n==25:?
Code:
# Copy your "Memento" code from the task in Lab 6.
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
... |
3 | 1 | TA | Please tell me about the function and role of the plant() function. | from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot(beepers=100)
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def plant_beeper(): # If hubo is not on beeper, plant a beeper
if not hubo.on_beeper():
hubo.drop_beeper()
# Scans 2 floors(rows) wh... | 29 | 44 | variable | This is the code that checks if there is no beeper where the robot is located, and if not | cs1qa | null | null | null | null | null | Question:
Please tell me about the function and role of the plant() function.
Code:
from cs1robots import *
load_world('worlds/harvest3.wld')
hubo = Robot(beepers=100)
hubo.set_trace("blue")
def turn_right():
for i in range(3):
hubo.turn_left()
def plant_beeper(): # If hubo is not on beeper, plant a be... |
4 | 2 | TA | What could be the reason? | import math
sin = math.sin
pi = math.pi
n=int(input('How many steps? '))
for i in range(n):
x = float(i) / (n-1) * 2 * pi
print (sin(x)) | 5 | 5 | reasoning | This is because the input state is not an integer, but a string, so in order to use a loop and calculate using the received value, it must be converted to an int. | cs1qa | null | null | null | null | null | Question:
What could be the reason?
Code:
import math
sin = math.sin
pi = math.pi
n=int(input('How many steps? '))
for i in range(n):
x = float(i) / (n-1) * 2 * pi
print (sin(x)) |
1 | 3 | TA | What is the role of the harvest_1() function in Task4? | from cs1robots import *
load_world('worlds/harvest1.wld')
hubo = Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def U_turn_left():
hubo.turn_left()
hubo.move()
hubo.turn_left()
def U_turn_right():
turn_right()
hubo.move()
turn_right()
... | 18 | 23 | variable | harvest_1 is a function of picking up the beeper of the odd line on the y-axis and then going up to the even line if there is a wall! | cs1qa | null | null | null | null | null | Question:
What is the role of the harvest_1() function in Task4?
Code:
from cs1robots import *
load_world('worlds/harvest1.wld')
hubo = Robot()
hubo.set_trace('blue')
def turn_right():
for i in range(3):
hubo.turn_left()
def U_turn_left():
hubo.turn_left()
hubo.move()
hubo.turn_left()
d... |
4 | 3 | TA | Why do you add 40 to the end of line 9 in the 4th task? | import math
sin = math.sin
pi = math.pi
cos = math.cos
for i in range(41) :
x = float(i) / 40.0 * 2 * pi
character_count_per_line = math.sin(x)+40*sin(x)+40# Change this line to print out sine curve correctly.
output_str = '#' * int(character_count_per_line)
print (output_str) | 8 | 8 | reasoning | I decided on the function, but I used trial and error a bit, but the first line was 40 #s. | cs1qa | null | null | null | null | null | Question:
Why do you add 40 to the end of line 9 in the 4th task?
Code:
import math
sin = math.sin
pi = math.pi
cos = math.cos
for i in range(41) :
x = float(i) / 40.0 * 2 * pi
character_count_per_line = math.sin(x)+40*sin(x)+40# Change this line to print out sine curve correctly.
output_str = '#... |
5 | 0 | TA | How did you use the balance variable in Task1? | balance = 0
def deposit(money) :
global balance
balance = balance + money
print("You deposited "+str(money)+" won")
def withdrawal(money) :
global balance
if money > balance :
print("You've withdrawn "+str(money)+" won")
print("But you only have "+str(balance)+" won")
else ... | 0 | 14 | variable | The balance variable is made available to all functions by using global to use in the newly defined function, and it means the total money in the bank. | cs1qa | null | null | null | null | null | Question:
How did you use the balance variable in Task1?
Code:
balance = 0
def deposit(money) :
global balance
balance = balance + money
print("You deposited "+str(money)+" won")
def withdrawal(money) :
global balance
if money > balance :
print("You've withdrawn "+str(money)+" won")... |
8 | 1 | TA | At the end, entering the country code and outputting the country name
Could you briefly explain how it was made? | import csv
f = open('average-latitude-longitude-countries.csv','r')
li1 = []
li2 = []
li3 = []
li4 = []
while True:
line = f.readline()
if not line:
break
line = line.strip('\n')
li = [1,1,1,1]
li[0] = line.split(',')[0]
a = line.split(',')[-1]
li[-1] = a.strip('"')
b = line.spli... | 41 | 47 | code_explain | After receiving the country code through input, the country code is output if the code is in the country code part of the list consisting of country code and country name | cs1qa | null | null | null | null | null | Question:
At the end, entering the country code and outputting the country name
Could you briefly explain how it was made?
Code:
import csv
f = open('average-latitude-longitude-countries.csv','r')
li1 = []
li2 = []
li3 = []
li4 = []
while True:
line = f.readline()
if not line:
break
line = line.s... |
2 | 0 | TA | Is there any reason why you didn't put the two for statements at the bottom of Task1 in the for statement at the top? | from cs1robots import *
load_world("worlds/harvest3.wld")
hubo=Robot()
hubo.set_trace("red")
def turn_right():
for i in range(3):
hubo.turn_left()
def beeper_pick():
while hubo.on_beeper():
hubo.pick_beeper()
hubo.move()
for j in range(2):
for i in range(5):
beeper_pick()
... | 16 | 43 | reasoning | At the very end, I didn't have to do the work of going up. | cs1qa | null | null | null | null | null | Question:
Is there any reason why you didn't put the two for statements at the bottom of Task1 in the for statement at the top?
Code:
from cs1robots import *
load_world("worlds/harvest3.wld")
hubo=Robot()
hubo.set_trace("red")
def turn_right():
for i in range(3):
hubo.turn_left()
def beeper_pick():
... |
6 | 2 | TA | What is the case for num1 and num2 that return False when is_valid in Task 3? | from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sungeun.jpg")
cards = []
num_pads = []
tries = 1
correct_list = []
def initialize():
# initial... | 81 | 99 | variable | If it already exists in correct_list, if num1 and num2 are the same, returns False if it is not an integer from 0 to 23. | cs1qa | null | null | null | null | null | Question:
What is the case for num1 and num2 that return False when is_valid in Task 3?
Code:
from cs1graphics import *
import time
import random
canvas = Canvas(640, 580)
canvas.setTitle("Memento")
path = "./images/"
names = ("Dohoo.jpg", "Jeongmin.jpg", "Jinyeong.jpg",
"Minsuk.jpg", "Sangjae.jpg", "Sun... |
10 | 0 | student | If you look at the animation execution code of Mario Code right now, there is no for statement. Can you still give a slow moving effect? | from cs1graphics import *
from time import sleep
_scene = None
_world = None
t = 0.2
def create_world():
global _scene, _world
if _scene:
raise RuntimeError("A world already exists!")
_world = _World(500, 300)
_scene = Canvas(_world.width, _world.height)
_scene.setTitle("Mario World")
... | 155 | 156 | code_understanding | mario's move is a function that only moves once | cs1qa | null | null | null | null | null | Question:
If you look at the animation execution code of Mario Code right now, there is no for statement. Can you still give a slow moving effect?
Code:
from cs1graphics import *
from time import sleep
_scene = None
_world = None
t = 0.2
def create_world():
global _scene, _world
if _scene:
raise R... |
8 | 2 | TA | What is the role of list1 and temp? | import elice_utils
f = open("tpmon.txt", "r")
temp = []
list1 = []
temp = f.readlines()
for i in range(len(temp)):
list1.append(0)
for i in range(len(temp)):
if i==0:
continue
list1[i] = temp[i].split( )
for i in range(len(list1)-1):
print('%d: %6.1f / %4.1f' % (int(i+1723), (float(list1[i+... | 4 | 5 | variable | temp is a list of files that have been read, and one column of the list contains a string of yearly weather, and list1 is a list that lets you know the monthly temperature by relisting the string of temp by month. | cs1qa | null | null | null | null | null | Question:
What is the role of list1 and temp?
Code:
import elice_utils
f = open("tpmon.txt", "r")
temp = []
list1 = []
temp = f.readlines()
for i in range(len(temp)):
list1.append(0)
for i in range(len(temp)):
if i==0:
continue
list1[i] = temp[i].split( )
for i in range(len(list1)-1):
pr... |
5 | 0 | TA | Please briefly explain when to use global! | balance=0
def deposit(money) :
global balance
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#################
# Do something on here !
balance=bala... | null | null | variable | Global is a global variable, and when used in two or more functions, we know that global is used. | cs1qa | null | null | null | null | null | Question:
Please briefly explain when to use global!
Code:
balance=0
def deposit(money) :
global balance
# Input : (Integer) The amount of money that a user wants to deposit
# Output : (None) No Output
# Add the money to the current balance
#################
### implement ###
#... |
2 | 2 | TA | Please briefly explain the code | from cs1robots import *
# Your code should work with any of the world files below.
# TIP: Press Ctrl + '/' (or Cmd + '/' if you are using a Mac)
# to comment out or restore the whole line of the code in the editor.
#load_world('worlds/hurdles1.wld')
#load_world('worlds/hurdles2.wld')
load_world('worlds/hurdles3.wl... | 26 | 30 | code_explain | Task 3 created a function over one hurdle and crossed the hurdle whenever the front was blocked. | cs1qa | null | null | null | null | null | Question:
Please briefly explain the code
Code:
from cs1robots import *
# Your code should work with any of the world files below.
# TIP: Press Ctrl + '/' (or Cmd + '/' if you are using a Mac)
# to comment out or restore the whole line of the code in the editor.
#load_world('worlds/hurdles1.wld')
#load_world('w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.