Lecture Materials

Questions & Answers


Q: Does this policy include the 'diagnostic' as well?

A1:  yes, it will include the diagnostic


Q: Brahm, what is the screen-pointing/flashlight tech you are using? I've seen several people using it and always wondered what it is/where I can try it out

A1:  its a special logitech clicker!


Q: Can we access the course lecture materials (slides, code) and zoom recordings after the course ends this quarter? I would like to go back to some assignments to practice writing the extensions over the Summer.

A1:  Yes for slides and code. As I understand it, the university canvas page doesn’t allow you to see the videos.

A2:  The cs106a website will get reset over the summer, since there will be a new offering of cs106a over the summer, so you might want to download the slides/code before then.


Q: So you will also be able to append to list1?

A1:  live answered


Q: when you rename a list, can you refer to that list with the original name?

A1:  if you do x = [] y = x you can refer to it as x or y!


Q: What is a “frame” exactly? Is it something physical? Is it just a model we use to visualize what is going on? What’s really happening inside the computer?

A1:  its a model. In your computer the frame exists as a set of sequential blocks of memory.


Q: is there a reason you need the double underscores for __name__ and __main__?

A1:  __name__ is a special variable in namespace which stores __main__ only if this was the file that was run


Q: So does it mean, that in reality you can call other functions in the if__ statement, not necesarilly main?

A1:  yes!


Q: Are there different contest prizes now that everyone gets to drop their lowest grade anyways?

A1:  Well, beside the glory of winning the contest :-), we'll replace your next lowest grade with a 100%. So, after we drop your lowest grade, you'll get a 100% on the next lowest.


Q: So all global variables are in the program namespace?

A1:  Global variables are in the namespace of the "module" they are defined in. If you only have one file/program, then they are in the namespace for that file/program.

A2:  live answered


Q: If a function is just an object, why do I need “def” in front of it? Why not be like foo(params) = (stuff in teh body of the function)?

A1:  Using def is the way python defines it. There are other languages that do something more akin to what you're suggesting. There is also something called a lambda function in python that you might want look up online that has some similarities to what you suggest.

A2:  thats a good point! There is a slight difference in python in syntax


Q: can you clarify what you mean by an instance variable? I think i may have misunderstood

A1:  An instance variable is a variable inside an object (instance of a class).


Q: why does brahm say “binding” when he refers to like assigning a name to a function object?

A1:  its a formal term for what you described


Q: what is the difference between binding and assignment

A1:  same thing!


Q: How is a function object different from a class?\

A1:  A class has both varables/attributes and a bunch of functions associated with it. You can create instances of the class, which are objects. A function is just a single function. It does not define a new type.


Q: so can we say that a function is like an “advanced” level of variables what can be assigned?

A1:  the idea is that you can store a function in a variable, or pass it as a parameter as a variable. So, you can just think of a function like a value in a variable, except that the function is something that can executed (not just a value you look up).


Q: so when you put things in a function, it changes the function object itself?

A1:  Not sure what you mean by putting things in a function. A function is an object that can be assigned to a variable or passed as a parameter.


Q: so you do not need () for copy of foo = foo ?

A1:  without the () it uses the function reference. With (), it calls the function


Q: why do we need a copy of the function?

A1:  If you want to have more than one way to refer to the function. It's not something that you commonly do. Rather, passing functions as paramters is a more common thing that happens in programs.


Q: So we don’t need to put ()? -> copy_of_foo() = foo() instead of copy_of_foo = foo?

A1:  correct. If you put the () your program will try and execute the function!


Q: does it purposefully not have a space between key , the equal sign, and get_len (ie key = get_len)

A1:  It's a stylistic convention in python. You could have spaces before/after the equal sign, but it stylistically not recommended in this case.


Q: And how can the program recognize the mouse click?

A1:  coming soon!


Q: How do you control where to place the button on the canvas?

A1:  Brahm is planning to talk about this soon!


Q: so command is another function?

A1:  correct!


Q: So would it return True or False if the bottom was pressed? I don’t get what this specifically return

A1:  live answered


Q: Why do you not put paratheses after click_handler in the line command = click_handler

A1:  the parens make a big difference here. With the parens, python calls the function. With no parens, python uses it as a variable


Q: But why do we want just to print that, if instead we want to go to another screen or do another function?

A1:  It's just to keep the program simple for class.


Q: How did Brahm add the eye emoji to the terminal lol

A1:  Its a character in strings :)


Q: brahm are you wearing a karel shirt

A1:  why not :)

A2:  Yes. Many swirling Karels!!


Q: But, can we do it?

A1:  Do what?


Q: the default location of the button is at 0,0? how do you place it at another spot of the canvas

A1:  it gets a little more complex. You need a container, and there are a few choices


Q: Wow I love Brahm’s commitment. Brought out a WHOLE mouse to click

A1:  ha :)


Q: Isn’t the starter code for sand full of global variables?

A1:  Yes. It wasn't written by us :-). Some python programmers will use globals when building applications for GUIs.


Q: Make the clicker_function to show another screen with new functions?

A1:  live answered


Q: Can you make a class for a type of function?

A1:  you can have a class with a function?

A2:  You can make a kind of class called a functor that is probably what you might have in mind for this. Search for "python functor" and you'll get a bunch of information.


Q: How is scrolling through a photo gallery on a smartphone similar to hitting the previous and next photo buttons on a computer?

A1:  The key difference between scrolling and using “pagination” like with previous and next, is the scroll bar. On the web you can put elements in scrollable panes


Q: Can the constest deadline be extended if needed, please?

A1:  live answered