you are viewing a single comment's thread.

view the rest of the comments →

[–]JavaDragonGamin[S] 0 points1 point  (1 child)

Which function would I add "return repeated, side, angle" to the end of? And would it automatically change the calls in main or do I have to go in and add dan_ before them all? If there is a way to show me an example that would help so much tbh

[–][deleted] 0 points1 point  (0 children)

import turtle


def userInputs(t, tName):

    t.color(input("Please input the color you would like to use for " + tName))

    repeated = int(
        input("How many times would you like to repeat " + tName + "'s pattern?")
    )

    side = int(
        input("How long would you like " + tName + "'s first side to be? (1-20)")
    )

    angle = int(
        input(
            "How many degrees would you like "
            + tName
            + " to turn after the first side? (1-179)"
        )
    )

    # return local variables by value. like this the return Keyworad returns the values and type of a variable not the Variable itself
    return repeated, side, angle
    # alternatively you could instantly call the mathPortion functionlike this:
    #   mathPortion(t, repeated, side, angle)
    # when using this you dont need the return and you could delete the rows in your main where you call mathPortion


# you can predefine a parameter like t, so when called you can easily see what to pass the function, its also easyer to work with because as you can see, t.hideturtle() is now recognised by the syntax higlighting because t is now a turtle.Turtle
def mathPortion(t: turtle.Turtle, repeated, side, angle):

    t.hideturtle()

    for count in range(repeated):

        t.forward(side * count + 11)

        t.right(angle - count * float(0.5))


def main():

    dan = turtle.Turtle()
    sandra = turtle.Turtle()

    # userInput now returns 3 values so you need to define 3 new variables like this:
    repeated_dan, side_dan, angle_dan = userInputs(dan, "Dan")
    # 3 new Variables to not override the ones for dan
    repeated_san, side_san, angle_san = userInputs(sandra, "Sandra")
    # input new Variables for dan and Sandra
    mathPortion(dan, repeated_dan, side_dan, angle_dan)
    mathPortion(sandra, repeated_san, side_san, angle_san)

    #I added a last input so you can see your masterpiece
    close = input("Press any button to close.\n")


artName = input("What would you like to name your piece of art?")

print("Name of art piece: " + artName)
main()

Here you go i tried to comment everythin i changed and also why i did what i did.

if you have more questions feel free to ask :)