Record Answers Here for lesson 22nd March 2022

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

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #7459
    May07
    Participant

    Python Program 2:

    Ceil()= round up
    Floor()= round down
    helps with finding the smallest and largest integer.

    #7461
    Hayeon Kim
    Participant

    Can a function have more than 1 argument?
    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.

    Yes, a function can have more than one argument, only if it matches the subject and is placed in the right location.
    Yes, arguments can be stored in variables, because sometimes the arguments might be displayed.
    I believe the order of the arguments do not make a difference, since things stated are things that are stated. Therefore, in whatever order the argument is made, I think it doesn’t matter, since it still states things that should be stated.

    #7462
    Hayeon Kim
    Participant

    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?
    – The purpose of the “Import random” is to randomize the variable and function. However, when I tried omitting the code, it did 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 have to replace 1-100 with 4-10.

    #7463
    Hayeon Kim
    Participant

    a. Explain what the ceil() function does.
    – The ceil() function returns the smallest value that is greater than or equal to a certain number.

    b. Explain the purpose of the floor() function.
    – Opposite to the ceil() function, the floor() function returns the greatest value that is less than or equal to a certain number.

    c. Why are the calls to the floor() and ceil() functions preceded by “math.”?
    – It’s used because it has to find the smallest/largest integer related to the given number.

    #7465
    aanya03
    Participant

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

    Can arguments be stored in variables?
    Yes, it can be stored in variables because a function can be assigned in variables.

    If a function contains more than one argument, do you think the order of the arguments makes a difference? Explain your answer.
    Yes, if there is more than one argument, then the difference will affect on the order of the printed function.

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