logotransparent.png

Legion of Learners

www.lol-101.com

  • Home

  • Classrooms

  • Courses

  • About Us

    • Executive Team
    • Board Members
  • Resources

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    Eric Wu
    Jul 18

    7/17 - Homework Week 6 Day 1

    in Introduction to Python

    Homework:

    1. 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.

    2. Write a function to reverse all the characters of a string.

    3. 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.

    5 comments
    0
    5 Comments
    justannie2019
    Jul 20

    teacherWeapon = {"A": "90 - 100, good", "B": "80 - 90, fair", "C": "70 - 80, poor", "D": "60 - 70, bad", "F": "0 - 60, sad"}

    embarrassingScore = input("What was your most recent test score? ")

    print(teacherWeapon.get(embarrassingScore))


    def stringReverse(s):

    x = ''

    y = []

    for i in range(len(s)):

    y.insert(0, s[i])

    for i in y:

    x = x + i

    return x


    def listMultiply(list279):

    x = 1

    for i in list279:

    x *= i

    return x

    Like

    E
    Eric Wu
    Jul 20

    Solution:

    Part 1:

    dict={"A":"100-90","B":"89-80","C":"79-70","D":"69-60","F":"59-0"}

    x=input()

    print(dict.get(x))


    Part 2:

    chars=""

    for i in reversed(input()):

    chars=chars+i

    print(chars)


    Part 3:

    num=1

    x=1

    while x!=0:

    num=num*x

    x=int(input())

    print(num)

    Like

    echeung0808
    Jul 19

    grades = {"A":"100 - 90","B":"89 - 80","C":"79 - 70","D":"69 - 60","F":"59 - 0"}

    i = input("What is the grade? ")

    print(grades.get(i))



    string = input("Input a string: ")

    x = ''

    for i in range(len(string)-1, -1, -1):

    x = x + string[i]

    print(x)



    list1 = []

    a = 1


    while int(a) != -1:

    list1.append(int(a))

    a = input("Give me a number to multiply. If you are done, type in -1: ")

    x = 1

    for i in list1:

    x = x*i

    print(x)


    Like

    melodychangchang
    Jul 18

    Part 1:

    grades = {"A":"90%-100%", "B":"80%-89%", "C":"70%-79%", "D":"60%-69%", "F":"0%-59%"}


    letterGrade = input("Input letter grade: ")

    print(grades.get(letterGrade))


    Part 2:

    def reverseStr(string):

    output = ""

    for i in range(len(string)-1, -1, -1):

    output += string[i]

    return output


    print(reverseStr("reverse this message"))


    Part 3:

    def multiplyList(list):

    product = 1

    for i in list:

    product*=i

    return product


    print(multiplyList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))

    Like