Home › Forums › Python Functions › Record Answers Here for lesson 22nd March 2022
- This topic has 19 replies, 14 voices, and was last updated 3 years, 3 months ago by
aanya03.
- AuthorPosts
- March 22, 2022 at 12:45 am #7433
Eamonn
KeymasterRecord Answers Here for lesson 22nd March 2022
March 22, 2022 at 1:49 am #7437Peam1223
Participantthe output
64 71 71 60 39the 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).
March 22, 2022 at 2:06 am #7438bambam
Participant1. 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 .March 22, 2022 at 2:07 am #7439Rafael
ParticipantThe 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 numberProgram2
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.March 22, 2022 at 2:09 am #7440Chien493
Participantyes
yes
Arguments must be given in the order expected by the functionMarch 22, 2022 at 2:11 am #7441Peam1223
Participanti think the ceil() function rounds the number up
i think the floor() function rounds the number downprint(math.ceil(x))
print(math.floor(x))March 22, 2022 at 2:13 am #7442Karan123
ParticipantCan 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.March 22, 2022 at 2:18 am #7443Rishi
Participant1. 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 lastMarch 22, 2022 at 3:00 am #7448Fine
ParticipantCan 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.March 22, 2022 at 3:02 am #7449Andrew
ParticipantThe function could only have 1 argument
You can assign another variable
Its a syntax for math.March 22, 2022 at 3:04 am #7450VashiTokyo
ParticipantYes because sometimes you need more than one function in order to make the code work, for example:
window = turtle.Screen()March 22, 2022 at 3:05 am #7451Fine
ParticipantModules 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))March 22, 2022 at 3:09 am #7452Matthew Sparrow
ParticipantYes, 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.March 22, 2022 at 3:11 am #7453Fine
ParticipantModules 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.March 22, 2022 at 3:32 am #7457May07
ParticipantYes, 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. - AuthorPosts
- You must be logged in to reply to this topic.