Lecture Materials

Questions & Answers


Q: is lecture 11 on the website?

A1:  Sorry working on posting those notes right now.


Q: how are homework graded? sand is really hard, I don't think I'll be able to complete it

A1:  Sand is a challenging assignment! You have until Friday with the grace period. Feel free to post on Ed and come to LaIR to get help. We grade on functionality and style. You can definitely get partial credit if it doesn’t work perfectly.


Q: what happens to b when, after setting a = b, we change b?

A1:  Try it out! The short answer is it depends on the variable type. With ints, b doesn’t change when you change a.


Q: if instead we said b = 10, would the result be the same?

A1:  If we instead said that when?


Q: Can we pass floats to int()?

A1:  Yes! Try it out


Q: it says “object not found” when i click on lecture 11

A1:  How about now?


Q: So the strings always have quaotation marks around them?

A1:  Yes! Quotation marks means strings.


Q: Will we get the quiz results back today?

A1:  Yes! We will talk about the quiz at the end of lecture.


Q: Still issues with pulling lecture: URL link doesn’t work

A1:  Can you try refrshing the 106a homepage and trying again?


Q: hello! when will HM4 be released?

A1:  Tomorrow!


Q: hi i missed the beginning of lecture bc of wifi issues, will it be posted right after class today?

A1:  It takes a while to upload to Canvas, so probably an hour or two after lecture it will be up there. I start the upload right after lecture.


Q: Why is left + 1 there?

A1:  Because we want to start searching from 1 char in front of where the left paren was found.


Q: would starting at left also work because there is definitely no left paranthesis there anyway?

A1:  For the find cas you also could have started at left.


Q: what does the if left == -1 mean

A1:  left will be -1 if there is no left parenthesis in s. So that is checking if a left paren exists at all.


Q: why wouldn't we write right + 1

A1:  We only want to slice up to the right parenthesis. We do not want to include the right paren in the result string.


Q: why is the last line left minus 1

A1:  Which line has left minus 1?


Q: Can you remind me why he sets left and right equal to -1?

A1:  The double equal signs check if two values are the same. So he is not setting them equal to -1, he is checking if either of them are equal to -1. left will be -1 if there is no left parenthesis in s. So that is checking if a left paren exists at all. Same thing with right.


Q: why did we put if left... under left? why couldn't we have put it above the if right == -1 statement

A1:  We want the program to stop running once it knows that there is no left paren.


Q: I still don’t understand why we want to start searching from one char in front of where the left parentheses is?

A1:  You can search from left or left + 1 in the case. Often times you will want to repeatedly search for the same charcatrer. s.find returns the index of the first occurrence of a given character, so if you wanted to search for the same character in a string, you would want to start searching from left+1.


Q: Are we using -1 because that position is outside the scope of the string (0-n) and, therefore, always represents the case for no ‘(‘ ?

A1:  Yes! The people who invented the find function wanted some value to indicate that a char isn’t in a string and they arbitrarily chose -1.


Q: how do you check the number of bytes?

A1:  There is a way to check with a python function. You can also check the size of your file as Nick demoed a few mins ago.


Q: If you started a string with ' could you put " in without the backslash

A1:  yes


Q: Does python work in languages other than English, or does everything have to be coded in English?

A1:  Everything has to be coded in Python (using if, for, while, None, print(), etc), but people can choose different variable/function names and also their comments can be in other languages.


Q: you don’t need to write (1, 2, 3) as (‘1’, ‘2’, ‘3’)?

A1:  You can print them either way. Print turns whatever you pass in into a string.


Q: Is he demonstrating standard out text area with print? Doesn’t look any different from Terminal?

A1:  The default standard out text area is terminal. So when you have prints in your code in pycharm, they will show up in your terminal.


Q: Where is the >>> coming from after 123 in the last example (where end=' ')

A1:  Those go on every line in the interpreter automatically. Since we told print to use the separator ‘’ it didn’t go to a new line to put the >>>.


Q: who codes the interpreter?

A1:  great question! When you type python3 and start running the python interpreter, that comes with the download for python. So the inventors of python coded that. The terminal was coded by the same people who created the entire operating system for your computer (windows, OSX, linux)/


Q: comand line is the same as the terminal?

A1:  Yes


Q: is cat command line == print ()?

A1:  yes exactly


Q: are we using terminal in the PyCharm to do this?

A1:  Nick is on the terminal outside of Pycharm to demo, but you can use all of the this in the Pycharm terminal.


Q: When I write ls on terminal it doesn't work, is it because I am on Windows?

A1:  Yes! It is DIR in your command prompt. But inside Pycharm you should be able to use ls


Q: will the output be the same if we said “for i in f”? (instead of line)

A1:  Yes the name for the variable is line is arbitrary.


Q: would this result in an error if one of the characters was non alphabetic?

A1:  Luckily upper and lower do not throw errors if a character is non-alphabetic. They just don’t do anything to those characters.


Q: In the code that switches uppercase to lowercase and vice versa, does Python just ignore the special characters like @?

A1:  yes!


Q: what is the point of saying else when if the if statement doesnt work itll just go to the next line anyways

A1:  Because we only want to do that case if the if statement is false. If we didn’t use else, we would turn char to lower in all cases rather than just when the char is uppercase.


Q: what part of the code enables the -crazy in command line?

A1:  It is in the main. Those are called flags. Soon you will be able to write all of that code yourself. :)


Q: How do we get access to Gradescope?

A1:  You should be able to make an account with Stanford email and you will automatically be part of the 106A class.


Q: how do we access Gradescope?

A1:  You should be able to make an account with Stanford email and you will automatically be part of the 106A class.


Q: how do we access gradescope

A1:  You should be able to make an account with Stanford email and you will automatically be part of the 106A class.


Q: if we did well on this quiz but do badly on a later quiz, do we get the same adjustment?

A1:  We only improve your grade with the adjustment.


Q: Will the quiz weightage be adjusted per person? Or based on the whole class’s scores?

A1:  Per person if you you individually improve.


Q: What is the six-character course entry code in GradeScope? CS106A. ?

A1:  74E6RY


Q: Code is false alarm! Your email has resolved it.

A1:  Wooo hoo!


Q: i was able to join without a code

A1:  Yay thanks!


Q: sorry, i meant that if for example we get high grades on quiz 1 and 3 but poorly on quiz 2, is there also the possibility of an adjustment of that score? or is it only for quiz 1

A1:  I think we will do it for all the quizzes, but I wil check with Nick.


Q: I don’t see the Gradescope email

A1:  Email me and we can look into it :) you can try joining with the course code for now: 74E6RY


Q: will the other quizzes be cumulative of course material?

A1:  They will mostly test the most recent course material, but parts of it will be cumulative.