Lecture Materials

Questions & Answers


Q: Where do we see our quiz scores?

A1:  After class today on the class website :)


Q: Where will we be able to see our quiz score? Paperless?

A1:  On the class website :)


Q: Is there a way to switch which section you are assigned to, I can't makemy current one anymore

A1:  Please email the head TA Tara


Q: Sorry if this question is kind of stupid but I'm still a bit confused on what args and command lines are from yesterday

A1:  Not a stupid question! Args is a list that contains the user entered command line arguments. A command line argument are separated by spaces and entered into the terminal when you run your program. Please follow up with more questions or swing by LaIR/Juliette/Tara’s office hours. We would love to help you understand this fully :)


Q: Is this like csv data?

A1:  yep


Q: Do we vote for the pictures based on slide number?

A1:  Yep :)


Q: Is there a way to check what our overall grade in this class is right now?

A1:  No, but feel free to stop by Juliette or Tara’s office hours if you want to discuss your standing in the class


Q: Was submitting our picture to paperless the only requirement for the contest? I didn't see any other info on what to do but I guess I missed something

A1:  Yep submit a picture and your code. Not all submissions were included in the art show


Q: For slide 7 on the bluescreen submissions, the names under the slides are switched around with slide 9.

A1:  Thanks for letting me know! I’ve made a note :) Just to confirm, your submission is slide 9?


Q: Why do they store the data in TXT files. What is the benfit vs something that is more easy to read?

A1:  Great question! I’m not 100% sure on my answer but I think it may simply be because we’ve learned how to read .txt files. Let’s follow up with Juliette at the end :)


Q: can you explain the update again and why you have to do that

A1:  Yes! In a for loop, i is automatically updated. With while loops, we have to increment i ourself


Q: Could we use i++ to increment i?

A1:  Unfortunately no.


Q: yes

A1:  Great ty!


Q: Is there a stylistic preference between a for loop and a while loop in the way Juliette is showing?

A1:  When you can, use a for loop. If you cannot use a for loop (which we’ll see some examples for), then use a while loop.


Q: Does i++ work in python?

A1:  Unfortanately no


Q: How do we open the link to the voting form? It says I need permission.

A1:  Are you logged into your Stanford google account?


Q: Is it a requirement that we do the exercises, or can we just do the homework if we are short on time?

A1:  You do not need to do the in class exercises. You are only graded/required to do the homework. With that said, doing the exercises can help you with your homework and prepare you for the quiz :)


Q: does the at in end=at+1 mean the index we are currently at?

A1:  Yes! We stored the index for the @ symbol in the variable named at. So we want to start looping after the @ symbol (at + 1) and then we keep incrementing at (so it’s stores our current location)


Q: I am confused by the end += 1 What does this do? Thanks in advance!

A1:  Great question! end += 1 is equivalent to end = end + 1. We are incrementing the number stored in end by 1


Q: is it okay to just use a for loop to loop through the string and if finding an @ then you just read from there within the same loop. You store whether you found the string or not with a flag variable and you break out once the next char is not alpha

A1:  That would probably work. I would use a while loop instead because I try to avoid using break when possible


Q: could you quickly explain what end += 1 does? Thanks!

A1:  That’s how we increment our current index. end += 1 is equivalent to end = end + 1


Q: If we don’t do that well on the first quiz will it still be possible to get an A in the class?

A1:  No (depending on what not well equates to)! The quiz is only worth 20% of your grade. Say you get a 70% on the quiz but a perfect on everything else. You’ve only lost 6% of your overall grade (still within the range of an A). Feel free to stop by Juliette/Tara’s office hours to discuss grading more :)


Q: follow up questoin, why is it not good to use break in loops?

A1:  I was told that it was best style to avoid breaks when possible. There are definitely times when I have to use break but I try to avoid it because sometimes your logic can be simplified to avoid the break


Q: I'm a little confused. What does this code do?: word = s[at + 1:end]

A1:  This is taking a slice of a string. Get the characters in s from at + 1 up to but not including end


Q: on the hw due tonight i'm having trouble with the waterfall warmup, where can I go to get help?

A1:  So glad you’re asking for help! You can get help at LaIR tonight it’s open from 7-9pm PT. You can see more info in the Zoom links handout on the class website :)


Q: Does it matter whether end < len(s) comes before or after s[end].isalpha()?

A1:  Great question! Yes it does. We want to make sure that end is in bounds of the string before checking if it’s alphabetical. If you flipped the order your code would crash when end is outside of the bounds of s.


Q: how does the program know “end” is the end?

A1:  It doesn’t know that end is the end. We tell the computer that end is the end. This is just a name we chose for our variable. We could have called it pizza but that would not be a descriptive name


Q: On the quiz, can points still be taken off if each question is correctly solved for all cases?

A1:  If your code was general and has no bugs you cannot lose points. Style was not graded on this exam. Please follow up if you have more questions


Q: does s[1:3] basically mean grab the string at characters 1-3?

A1:  Almost! String slicing is inclusive of the start and exclusive at the end. So s[1:3] says grab the characters at 1 and 2 index


Q: the bluescreen voting form has the link to the spring 2021 slides… where can i find the correct ones?

A1:  https://docs.google.com/presentation/d/1tcmgE3fg4Nv9SYsLGWNKpB5H1N8hvF7hUqUE4CW8I6U/edit#slide=id.ge2de1b689b_0_149


Q: Ok, thank you for the previous reply! With that in find what does s[at +1:end] do? Does it slice the string from after @ to the last character?

A1:  s[at + 1 : end] starts at one character after the at index and slices up to but not including the end index


Q: what if there are multiple exclamation marks or @ ?

A1:  It will find the first instance


Q: does && and || work?

A1:  Not in Python. You have to use and for && and or for ||


Q: in C++, 1 is true and 0 is false, does this work in python? For example, if 1:

A1:  Yeah I believe that you can use if 1 in Python. However that would be poor style. It’s much better to use a boolean condition or true/false instead :)


Q: How do you run a Doctest on code in PyCharm?

A1:  Great question! You right click on the doctest and click run doctest. Feel free to stop by LaIR/Office hours if you want a demo :)


Q: Can't you just use alnum.()?

A1:  You could! s[end].isalnum()


Q: Should you decomp by var for the long while line of code?

A1:  Great question! In this case, that’s probably not necessary but I love that you’re thinking about decomposition :)


Q: I dont get how the [at + 1:end] works since end = at +1 so isnt that just [at + 1: at + 1] which would return zero?

A1:  Great question! Notice that we increment end by 1 inside the while loop until the while condition is not met. So end will not equal at + 1 unless nothing else is in the string


Q: what does 1:end mean at the end?

A1:  Great question! That was a part of the string slice command: word = s[at + 1 : end]. This is taking a slice of the string s starting at at + 1 and going up to but not incluuding the end index


Q: Where do we find the these questions on the experimental server? couldn’t find it in the previous

A1:  I think it’s in the parse section


Q: so could you use the final value of i without setting it after a for loop?

A1:  No. After the for loop ends we lose access to i


Q: Not too related but do you have any tips on getting stuck on code? I find it really easy for me to get frustrated when my code continuously doesn't work.

A1:  Take a break, stop by LaIR, use print statements


Q: What’s gradescope?

A1:  A website where you can submit/see assignments


Q: How do we know if we should request a regrade?

A1:  If you got marked off for an error that you don’t think is an error after looking at the answer key :)


Q: So do we get a number grade or a class rank?

A1:  Number grade (points earned)


Q: Will it be sent to us through email?

A1:  Yes and there will be an announcement on the course website.


Q: are you and juliette saying regrade request? for some reason i am having trouble understanding what you are saying

A1:  Yes regrade request. If you feel that you shouldn’t have been docked (gotten points off) after looking at the answer key then submit a regrade request


Q: were the code that we submitted for the quiz ran when being graded?

A1:  Your problem was graded by a human by tracing through your code without running it :)


Q: What kind of CS extracurriculars are there at Stanford? I know there is Stanford Women In Design (which I am a part of as a HS student), is there a parallel for CS?

A1:  Section leading (CS198), WiCS (Women in Computer Science), CS for Social Good, She++, Coding for her (or something like that)


Q: how were points deducted?

A1:  The ruburic will be released with the solutions :)


Q: just asking can you write conditions like this in python “condition ? condition is true : condition is false”

A1:  You cannot write ternary statements in Python


Q: do you have any advice for ppl applying to stanford

A1:  Come to office hours :)


Q: Is CS/Engineering at Stanford pretty close to 50% women and 50% men?

A1:  No it’s closer to 70% men and 30% women


Q: For masters in CS do you need to major in CS for undergrad?

A1:  No :)


Q: Will the quiz be on paperless or gradescope?

A1:  The quiz will be on gradescope not on paperless.