Asked by Rambo

What is the name of the user-defined function present in the following code snippet?*
import random
def test():
print("hello world")

randomNumber = random.randint(1, 10)
length = len("This is cool")
print(randomNumber, length)
test()
test
random
randint
len

Answers

Answered by Rambo
What does DRY stand for?*
Don’t Repeat Yourself
Do Repeat Yourself
Don’t Recall Yourself
Don’t Revise Yourself
Answered by Rambo
What is the output of the following code snippet?*
def say_something():
print("I said something")
def print_something():
print("I printed something")
print_something()
I said something I printed something
I said something
I printed something
None of the options
Answered by Rambo
Which of the following built-in functions returns the length of a list?*

length()

min()

len()

max()
Answered by Rambo
Which of the following is not a relational operator?*
>=
!=
==
+=
Answered by Rambo
8. In the following code snippet, what should go in the ___ to loop through the `users` list?*
users = ["Daniel", "Ivann", "Natalie", "Kevin"]
for user in ___:
print(users)
user
users
list
None of the options
Answered by Rambo
Write a Python program based on these instructions:*
Create a `Funny Nickname` app.
This app should ask the user for their first name and then create a
nickname in the form "[nickname] [first_name]"
Hints:
- Import the function to choose a random item from a list.
- Create a list of at least 4 possible nicknames of your choosing.
- Prompt the user for their first name.
- Combine their first name with a random nickname from the nicknames list.
- Display their name/nickname with a message like: "What's up [nickname] [first_name]!"
- You should replace anything in [] with the value of the variables.
Answered by Rambo
Write a Python program based on these instructions:*
Create a program that prompts a user to repeatedly guess a number.
Keep a tally of how many guesses it takes them to guess the number.
Once they guess the number, tell them how many guesses it took and end the program.
Hints:
- Generate a random number.
- You should use a function to do this so it's truly random
- Create a variable to track the `number_of_guesses`.
- Create an indefinite loop.
- Inside the loop:
- Prompt the user to guess the random number.
- If the user's guess is the same as the random number.
- Display a message saying: "That's correct, it took [number_of_guesses] for you to guess the number!"
- You should replace [number_of_guesses] with the value of the variable.
- Exit the loop.
- If the user's guess is NOT the same as the random number.
- Display a message saying: "Sorry, try again!".
- Add one to the `number_of_guesses`.
There are no AI answers yet. The ability to request AI answers is coming soon!