Lecture Materials

Questions & Answers


Q: Hi! I hope you are doing good today! I understand how to find the start of the word. But I am not too sure how the computer knows where the end of the word is?

A1:  Hi Mikhail! I am doing well today! Hope you are too :) Really great question the computer technically knows the end if you use len(s). But to find the end of our string (since we don’t want the whole string) we use a variable to track when to stop. I answered a question but maybe not yours so please follow up with you still have questions!


Q: Why did she write start = 0 instead of start = s[0]?

A1:  We want to start at the beginning of the string so index zero. Start is tracking indices and then we’ll use string slicing to get our string of interest


Q: for the second part of HW 4, we can only do it after Monday right?

A1:  mmm great question! I believe you can do the ethics questions based off of Katie’s lecture earlier this week. But let’s confirm with Juliette at the end :)


Q: does start++ work?

A1:  Not in Python. You have to use start += 1 :)


Q: can you explain why end = start + 1 again?

A1:  Yep! So we want to begin finding the end AFTER the beginning of our string. We already know that the char at the start index should be included in our string so we want to start searching after the start


Q: When’s the next quiz, and how many quizzes are left? Thanks

A1:  Only one quiz left on Friday of wk 7 (August 6th)


Q: why do we set end = start + 1?

A1:  Yep! So we want to begin finding the end AFTER the beginning of our string. We already know that the char at the start index should be included in our string so we want to start searching after the start


Q: can you use one for loop and use a variable to store whether or not the string’s beginning has been found; is reading the string; or finished reading

A1:  Yes that would probably work! We prefer the double while loop solution but there’s definitely more than one way to solve this type of problem :)


Q: Would the none in this case be considered an edge case?

A1:  The if start == len(s) if statement handles edge cases like no alphabetic chars or the empty string


Q: i still don’t understand end = start + 1

A1:  Thanks for reaching out! Start is going to point to the beginning of the string slice. We want to begin searching for the end one character (or index) after the start index. We use end to store the end of our string slice. Please follow up with more questions or swing by LaIR if you need some live help :)


Q: Did she say this will be on our next quiz/hw?

A1:  Yes! This will be on HW 5 and a main topic for the next quiz (Fri, wk 7)


Q: when is the next quiz?

A1:  Friday of wk 7 (August 6th). Course info here: https://web.stanford.edu/class/cs106a-8/handouts/generalInfo.html


Q: Will we be going over canvas stuff in section this week?

A1:  Not this week. This week is strings, file reading, and main to prepare you for HW 4. I believe next week is the Canvas stuff (because HW 5 covers Canvas). If you have questions about the Canvas material please stop by LaIR, Juliette/Tara’s office hours, or email me (since I’m your section leader) :)


Q: Whats the difference between n-1 and height-1? Im a little confused on that part.

A1:  Great question! n is an integer indicating the number of lines to draw. Height is the height of the Canvas :)


Q: what is top + height - 1

A1:  You have to subtract 1 because Canvas’s are zero indexed. Top is the starting place and height is what you want to add


Q: Hi - Why is it top + height - 1 and not just height?

A1:  You have to subtract 1 because Canvas’s are zero indexed. Top is the starting place and height is what you want to add


Q: What would happen if you put n+1 instead of n-1?

A1:  The spacing would be incorrect. If you want 4 lines, you want the start to be 0 then 1, 2, 3. :)


Q: so top is the existing y value and we were adding height to it?

A1:  Yes, top is the part of the coordinate for the upper left corner (the “start”) and then we added our height


Q: can you remind me how we do division and return back an integer?

A1:  Yes, to do integer division you use two slashes // :)


Q: Random question but what does Juliette press on her computer to see all of her apps open at once? It looks a lot easier than dragging tabs all over the place ;)

A1:  I have no idea actually lol. I’ll ask her at the end :)


Q: Just curious, how come there are 2 copies of each drawing for the past examples we’ve done?

A1:  Can you clarify what you mean by 2 copies?


Q: can you explain flex again?

A1:  Flex is a command line parameter that is a number between 0 to 1. It computes h. Percentage of length of arrow that you want to draw


Q: what does the head_len do again?

A1:  live answered


Q: Is it this weeks sections we will work on drawing or next week?

A1:  Next week! This week is strings and file reading in preparation for assign 4. If you have drawing questions, please stop by LaIR! We love to help students with conceptual understanding :)


Q: As in two sets of the red lines, two lines with arrow heads, or two sets of green lines

A1:  I think you’re referring to the arrow problem. We are drawing another copy of the arrow with our code.


Q: is flex universal or a function/parameter we defined?

A1:  We defined flex :)


Q: For the second part of homework 4, we cant complete that until after Monday’s lecture 7/19, correct? And how are we graded on that?

A1:  Ethics questions are graded on completeness and thoughtfullness of your answers. We want to see that you engaged with the material :) You can already complete the assignment based off Katie’s lecture this week


Q: do we submit a pdf or a word file? can we just type it in google docs or something?

A1:  There will be a .txt file in the starter code where you should type your answers. Make sure to submit that file on paperless :)

A2:  Correction: You do a download from the 4b handout not in the starter code


Q: Can we have a copy of Katie’s slides?

A1:  Yes! They will be posted by the end of the week


Q: Is the encyrption class puzzle mandatory?

A1:  Not mandatory just for fun :)


Q: What does Juliette press on her computer to see all of her apps open at once? It looks a lot easier than dragging tabs all over the place ;)

A1:  Scroll out with four fingers


Q: is the puzzle a english sentence or a python code?

A1:  English sentence not python code