top of page

Forum Posts

Eric Wu
Feb 19, 2023
In Introduction to Python
Homework: Create an array that represents a student's grades The student wants to check which classes they have As in. Print the elements of the array above 90.0. A new semester has started. Add a new axis so that the original array is now one row. Then, add a new row with six floats from 70.0 to 100.0. Let’s say the student drops their fourth period class, so they can no longer view their grades. Remove that column of the array. Lastly, they want to see how much they’ve improved from first to second semester. Print the difference between each of the columns. Recourses: Slides: https://docs.google.com/presentation/d/1bu_Z0OhYkfBKa-esKnCwN960jMUQzQk3ktbh_sMGZys/edit?usp=sharing Code: https://replit.com/join/sngzpindqi-shrav816 Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
1
16
Eric Wu
Feb 05, 2023
In Introduction to Python
Homework: Create a class Point. Attributes: x, y String representation: (x, y) Methods: translate(self, moveX, moveY): adds moveX to x and moveY to y dist(self, p) where p is another Point: calculates distance between two points Create two points. Find the distance. Translate one point 4 units left and 3 units up. Find the new distance. Recourses: Class slides: https://docs.google.com/presentation/d/1yG4Tdux4eBxCvBTNu840gISgyg2C-nmjkbZOk4PKczc/edit?usp=sharing Class code: https://replit.com/join/biwwaovqdx-shrav816 Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
2
16
Eric Wu
Jan 16, 2023
In Introduction to Python
Homework: Create a class. Initialize three parameters in a parameterized constructor. However, include “just in case” default values in the header (see “Combining both types of constructors” in slides.) Write one class variable. Write an accessor method that prints the values of all attributes. Write a modifier method for each attribute. Can we change class variables with our usual modifier method? Recourses: Class slides:https://docs.google.com/presentation/d/14oVru9bDjB9n1JAjho_T3defWE8aU1Evin1JPFeOdnI/edit?usp=sharing Class code: https://replit.com/join/zwdsmkhhom-shrav816 Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
2
36
Eric Wu
Dec 22, 2022
In Introduction to Python
Mini-Project/Homework Create the lists noun, verb, adjective, and adverb, and give them as many elements as you want. Import the random module. (We’ll be using random.choice() to select random words from the lists.) Open a file called “madlibs.txt”. Since it doesn’t already exist and you want to be able to read it afterward, what mode should you use? Write lines into it that create your story. Remember to add a new line character after each line! Each line should contain one randomly selected word from the list. Ex: f.write(f'Once upon a time, there was a {random.choice(adj)} {random.choice(noun)} in my backyard.\n') Read the entire file after the story is finished. Make sure the cursor starts at 0. Resources: Slides: https://docs.google.com/presentation/d/1GJ0GfDy0XPqqW4byO-bFVEkw1LwE_lX0VQo3sC5Beq8/edit?usp=sharing Class code: https://replit.com/join/nbrzbntycr-shrav816 Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
1
17
Eric Wu
Dec 11, 2022
In Introduction to Python
Homework Create a list that looks like this: [“ 9”, “8 7”, “0 ”, “ 2 ”]. Use map() to remove all spaces in each string (hint: replace()) Create a list of strings. Use filter() to print a list of all palindromes (words that are the same both forward and backward) Write a defined function addNumber that returns a lambda that adds the function parameter to the lambda input/parameter. Ex: if your function parameter is a and your lambda parameter is b, your lambda output should be b + a Define a variable (addFifty if a = 50, addTwo if a = 2, etc) that calls your function with a specific value for a. Use the function variable to calculate different numbers with different values for your lambda parameter. Hint: look at slide “def Functions with lambda” and the class code Try if an inputted number is being divided by 0. If it is, raise an exception. Resources: Slides: https://docs.google.com/presentation/d/1YIsLblmj8ysy9Q4aWdZsJiuzVR6jyYUsVp0KRPaEUE0/edit?usp=sharing Class code: https://replit.com/join/myprpmfxgv-shravyas Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
0
18
Eric Wu
Nov 08, 2022
In Introduction to Python
Homework Math expressions: Write and calculate these expressions in Python. e^5 Ceiling function of the square root of 127 Card exercise Create a tuple to represent the four suits of cards (hearts, diamonds, spades, and clubs), and another tuple for 13 possible values (2 - 10, J, Q, K, A). Iterate over all possible cards. Using the random module, deal three random cards. Sets Take input for the elements of a set (space-separated integers). Create the set, and then create another set. Print the intersection/elements in common. Resources: Slides: https://docs.google.com/presentation/d/1hi_-88CqHDAJwl9RUiJnrb5QTC3sjLGAQT2klFYm7iY/edit?usp=sharing Class code: https://replit.com/join/ctozgytivw-shravyas Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
4
51
Eric Wu
Oct 24, 2022
In Introduction to Python
Homework: Let’s say you have three shirts and four pants. Print every possible combination using a list for the shirts and a list for the pants. (Hint: list comprehension.) “Brian, the officer in charge; Mark, the chef; Dexter, my dog; and Petunia, my cat”. Split this string only by the first two semicolons. Find the index of the first t, the first x, and the first z. Resources: Class slides: https://docs.google.com/presentation/d/1ZTJES07Y4f7P5JrHNQz-2pIJH0nmTCpvm5kHVGd-PXQ/edit?usp=sharing Class code: https://replit.com/join/xfdqkiwkwr-shravyas Completed game: https://replit.com/join/akmhvbfxsh-shravyas Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
4
40
Eric Wu
Oct 15, 2022
In Introduction to Python
Homework 1. Print a pattern where the first row has one A, second row two Bs, third row three Cs, etc. A B B C C C D D D D E E E E E (so on and so forth) 2. Print a pattern where the first row has A, second row has B C, third row D E F, etc. A B C D E F G H I J K L M N O (so on so forth) Hint: you’ll need an additional variable outside the for loops for the index of string of letters. 3. Create a list of numbers, then use a for loop to multiply all the elements. Next, append a new element while removing a different old one, and then repeat the process of multiplication. Print both products. Resources: Class slides: https://docs.google.com/presentation/d/1ML3hll2J9nWQNLFKON2JHnkiJnzUpEy9uPNKTluMnD0/edit?usp=sharing Class code: https://replit.com/join/qlpoayfbyz-shravyas Contact Info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
8
62
Eric Wu
Sep 26, 2022
In Introduction to Python
Homework: Which operator makes each of these expressions true? (There’s more than one right answer!) “i can” ? “CODE” float(True) // 7 ? 0.0 “yEET” ? “y e e t” 2. Is each expression true or false? (6.3 + 7.2 / 2 == (6.3 + 7.2) / 2) OR NOT(2 * int(7.4) > 14) (“mat ” > “mate”) != (“for” > “Forward”) AND (7 > 8) != (9 > 6) 3. Use if-elif-else statements to create a grading system where user inputs a percent grade (0 to 100). If grade is between 100 and 90: print “A” else if grade is between 90 and 80: print “B” else if 70-80: print “C” else if 60-70: print “D” else: print “F” Resources: Class slides: https://docs.google.com/presentation/d/1Y9xOne9n70BlgKDi_uHrZ7gNNp_xivcQchEAE60kgvY/edit?usp=sharing Class code: https://replit.com/@ShravyaS/IntroToPython-Class3#main.py Contact info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
5
53
Eric Wu
Sep 12, 2022
In Introduction to Python
Hello everyone! I hope you all had a great first class. Here is your first homework assignment. Solutions will be posted later this week. Let us know if you get stuck on something and need some help. Homework: Giver 3 examples of each data type (2 for Boolean) Create the variables name, grade, color, and another variable for something you like. Use f-strings/concatenation to print the following string but with your information: Shravya is in 11th grade, and her favorite color is blue. Shravya's favorite movie is Thor: Ragnorok. Resources: Class slides: https://docs.google.com/presentation/d/198KFEj0Y9F2lbD_pV5QoxOBBly_hCVr_zYyoJ_kBrnM/edit?usp=sharing Class code: https://replit.com/@ShravyaS/IntroToPython-Class1#main.py Discord: https://discord.gg/28D6hGXP Contact info: shravyassathish@gmail.com (mentor) kingericwu@gmail.com (TA) felixguo41@gmail.com (TA)
0
11
142
Eric Wu
Aug 01, 2022
In Introduction to Python
There was no class on Sunday last week so there is no recording for that day. Homework: Use recursion to determine the nth term of an arithmetic series. Parameters: starting term, common difference, n. The formula for the nth term is a_n=a_(n-1)+d. Write a lambda that checks if a tuple of integers is a square. Then apply map() and print out the list result. (Hint: one approach is to use math.sqrt()). Resources: Slides: https://docs.google.com/presentation/d/1geOoU09YAzWQuYqReMEQ-y8erSqyeew6ESyH28_RRD0/edit?usp=sharing Class code: https://replit.com/join/lqjxuqxbqy-shravyas You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
0
3
14
Eric Wu
Jul 25, 2022
In Introduction to Python
REMINDER: There is no class on Sunday (7/24) Homework: Finish the game. Here are some specific instructions. - Print the Pico Fermi Bagel output from the getClue function - Check special case 1: if the guess matches the secretNum (exit all while loops) - Reduce number of guesses by 1 each turn - Check special case 2 outside of the while loop "while numOfGuesses > 0:" - Set game = False in either special case - Try running and debugging your finished code. If you can't seem to figure what's buggy, check against the completed code Resources: Slides:https://docs.google.com/presentation/d/1D6y1vuHr2LdxzM0r1PLLHs0QPESfuiLO8Gn_gB_LHnA/edit?usp=sharing Class code: https://replit.com/join/ycfkxwycuv-shravyas Pico Fermi Bagel Game Code (Completed): https://replit.com/join/ovchorqkie-shravyas You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
0
1
24
Eric Wu
Jul 18, 2022
In Introduction to Python
Homework: Create a dictionary that corresponds a letter to a set of numbers for grades (A = 100-90, B = 89-80, etc). Take user input for a letter and then print the appropriate grade range. Write a function to reverse all the characters of a string. Write a function that takes a list and multiplies all the elements together. Resources: Class slides: https://docs.google.com/presentation/d/1YP329tgCan7mXNj7ZcnjHDx UKm9ccPsvHKt1mss6ylE/edit?usp=sharing Code: https://replit.com/join/muzkblsbjr-shravyas Coding platform: replit.com Post your answers as a comment! I will post the solution before next class. You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
0
5
42
Eric Wu
Jul 11, 2022
In Introduction to Python
HOMEWORK: Finish adding all the bonus features to your Battleship game if you haven't already Generate a 4-by-4 nested list with random integers from 1 to 16 inclusive, and print them in a grid format Use the random module to generate random ships for your Battleship game. Look at the slides from class for more details. RESOURCES: Class slides: https://docs.google.com/presentation/d/1iMDChZz-abSDTKaH1ainjqJsDMvZeOb2BJ7Q1baeXFE/edit? Battleship code: https://replit.com/join/hlutbjbnyh-shravyas Example code: https://replit.com/join/butpfsjykv-shravyas Coding platform: replit.com Post your answers as a comment! I will post the solution before next class. You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
0
1
31
Eric Wu
Jun 23, 2022
In Introduction to Python
Homework: Using nested for loops, print a triangle with this pattern: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Create a list. Using a while loop, keep taking user input, and add the input to a list until the user enters “STOP”. Then, print all the elements of the list backwards, spaced with a tab. Iterate through a loop of positive and negative integers. If the element is positive, append it to a new list. Print the new list. Use either for i in listName or for i in range(len(listName)) Resources: Class slides: https://docs.google.com/presentation/d/1sOa_dL0L5SY4MS3t7HqVnIOU-PW4F9Ze_ZOgh0ySVmQ/edit?usp=sharing Code: https://replit.com/@ShravyaS/IntroToPython-Wk3Day1#main.py To view the code, open the link, and on the top left of the box, there is a button to show files. Click that and then click on main.py. If I got something wrong or it doesn't work send me a screenshot and I'll figure it out. Coding platform: replit.com Post your answers as a comment! I will post the solution before next class. You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
0
3
60
Eric Wu
Jun 20, 2022
In Introduction to Python
HOMEWORK: Take user input for a number and find its factorial (ex: 5! = 5 * 4 * 3 * 2 * 1 = 120) using a for loop. Take user input for someone’s full name. Then create a separate variable for only their first name, and greet them in the format “Have a great day, {firstName}!” One approach: For loop to locate space. First name = before space. Use nested loops to print 3 rows: the first with all numbers from 1 to 10, the second with all their squares, and the third with all their cubes. Use end=' ' parameter in inner loop and print(‘\n’) in your outer loop (under the inner loop) for correct spacing. RESOURCES: Class slides: https://docs.google.com/presentation/d/1DpbCZWxsHFFkeYu6DJOHEDSKzi0I0DudeHR8OiBTSK0/edit?usp=sharing Example code: https://replit.com/@ShravyaS/IntroToPython-Wk2Day2 Coding platform: replit.com Post your answers as a comment! I will post the solution before next class. You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
0
4
35
Eric Wu
Jun 16, 2022
In Introduction to Python
HOMEWORK: Part 1: Use if-elif-else statements to create a grading system where a user inputs a percent grade (0 to 100). if 100-90 = A else if 89-80 = B and so on Part 2: Use a while loop to print a pattern starting from 1 and ending at 46 where the difference between terms increases by 1: 1, 2, 4, 7, 11, 16, 22, 29, 37, 47 Hint: You will need 2 different variables. One of them will be the number you print and the other will be the amount you add. RESOURCES: Class slides: https://docs.google.com/presentation/d/1UlxFWDgPrOBy-5pybRom5_nRyehCyvPIN2n3mc3Sgkw/edit?usp=sharing Example code: https://replit.com/@ShravyaS/IntroToPython-Wk2Day1 Coding platform: replit.com LOL Discord: https://discord.gg/dWVUBmPx Post your answers as a comment! I will post the solution before next class. You can always email us at shravyassathish@gmail.com (mentor) or kingericwu@gmail.com (TA) or message us on Discord if you have any questions about the homework or what we covered in class.
0
6
57

Eric Wu

Forum Moderator
More actions
bottom of page