Record Answers Here for lesson 22nd March 2022

Home Forums Python Functions Record Answers Here for lesson 22nd March 2022

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #7433
    Eamonn
    Keymaster

    Record Answers Here for lesson 22nd March 2022

    #7437
    Peam1223
    Participant

    the output
    64 71 71 60 39

    the purpose of random is to generate random number. if you leave out import random, then an error will occur. you can change it to choose a random number within the range of 4 to 10 by changing the (1,100) in print(random.randint(1,100)) to (4,10).

    #7438
    bambam
    Participant

    1. We can pass no arguments at all , single arguments or multiple arguments to a function .
    2. We can assign a function to a variable.
    3 .Use pass by reference instead of pass by value .

    #7439
    Rafael
    Participant

    The function can only have 1 argument but can combine functions in one argument.
    The function can be assigned to a variable.
    The order of the argument makes difference. The order of the argument decides which one goes first and which one goes last.
    The import random => makes the random number

    Program2
    a. CEil() function rounds the number up to the nearest integer.
    b Floor() function rounds the number down to the nearest integer.
    c. THe syntax for both functions are same as the syntax for math.

    #7440
    Chien493
    Participant

    yes
    yes
    Arguments must be given in the order expected by the function

    #7441
    Peam1223
    Participant

    i think the ceil() function rounds the number up
    i think the floor() function rounds the number down

    print(math.ceil(x))
    print(math.floor(x))

    #7442
    Karan123
    Participant

    Can a function have more than 1 arguments?
    Can arguments be stored in variables?
    If a function contains more than one argument, do you think the order of the arguments makes a difference? Explain your answer.

    I think that a function can have more than one argument if everything in the syntax is placed correctly and right. Known as predifined functions.
    Arguments can be stored in variables because functions don’t have to come in every line, they are known as predifined functions
    Yes, I do think this because the amout and even the order of the arguments combined makes a huge difference as it can decide and change the order.

    #7443
    Rishi
    Participant

    1. One function can only have 1 argument because you cannot combine arguments
    2. You can assign a function to another variable
    3. Yes, I believe that the order of the argument makes a difference because it decides what goes first and what goes last

    #7448
    Fine
    Participant

    Can a function have more than 1 argument?
    – Yes, a function can have more than 1 argument if the arguments are combined and placed correctly.

    Can arguments be stored in variables?
    – Yes, an argument can be stored in variables because a function can be assigned to a variable.

    If a function contains more than one argument, do you think the order of the arguments makes a difference? Explain your answer.
    – Yes, if a function contains more than one argument, there will be a difference. Since the function are written in order, adding more arguments will affect the order of the printed function.

    #7449
    Andrew
    Participant

    The function could only have 1 argument
    You can assign another variable
    Its a syntax for math.

    #7450
    VashiTokyo
    Participant

    Yes because sometimes you need more than one function in order to make the code work, for example:
    window = turtle.Screen()

    #7451
    Fine
    Participant

    Modules in Python

    Run the program multiple times, and write down the output below.
    What is the purpose of “import random”? What happens if you omit that line of code?
    – Import random is when the program randomizes the variable. If you omit the code, the code will not work.

    How could you change the arguments of the randint function to choose a random number within the range of 4 to 10?
    – You basically change the number inside from 1-100 to 4-10, or the range of numbers that you want.

    code:
    import random
    print(random.randint(4,10))

    #7452
    Matthew Sparrow
    Participant

    Yes, a function can have more than one argument when it is placed and used correctly.
    Yes, arguments can be stored in variables.
    Yes, I think it makes a difference because it depends on where you place your arguments, if placed differently it might display different.

    #7453
    Fine
    Participant

    Modules in Python Program 2

    a.Explain what the ceil() function does.
    – ceil() function returns the ceiling of x as an Integral. This is the smallest integer >= x.

    b.Explain the purpose of the floor() function.
    – foor() function returns the floor of x as an Integral. This is the largest integer <= x.

    c.Why are the calls to the floor() and ceil() functions preceded by “math.”?
    – It is used to find the smallest and largest integer.

    #7457
    May07
    Participant

    Yes, a function can have more than 1 arguments.
    Yes, arguments can be stored in variables.
    Yes, it can make a difference. Order is very important and it can be changed as we place new arguments.

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.
Scroll to Top