Question

Please insert in your code the number of the question and the question itself, followed by...

Please insert in your code the number of the question and the question itself, followed by the piece of code that is your answer to that particular question. You can comment multiple lines in Python with “”” commented fragment””” or a single line by #commented line.

  1. Define function that asks user for his/her name and displays it.

  2. Define function that takes a name as a parameter and displays the name

  3. Define function “smallest” that returns the smallest number from a given list.

  4. The following code has an error. Please fix the error and make the code display both listA and listaB:

defask5num():

        l=[]

        fori inrange(1,6):

            number = input("plase provide a number: ")

           l.append(number)

listA = ask5num()  

print("listaA is:  ",listA)      

listB = listA +[1]

print("listaB is:  ",listB)

  1. Please write two functions.

  • Function one to create a local variable called “a” that equals the sum of a global variable called “glob” plus 10.
  • Function two to create a variable “b” that is the sum of the same “glob” variable plus 100.

Please display the global variable and both local variables. Set your global variable to 1000.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# function that asks user for his/her name and displays it.
def displayinput():
name = input("Enter your name: ")
print(name)

# function that takes a name as a parameter and displays the name
def printName(name):
print(name)

# function “smallest” that returns the smallest number from a given list.
def smallest(a):
mini = a[0]
for number in a:
if number < mini:
mini = number
return mini
  
displayinput()
printName("Ellen Degeneres")
print(smallest([4, 5, 3, 6, 2, 8]))

# highlighted are the changes made

def ask5num():
l=[]
for i in range(1,6):
number = input("plase provide a number: ")
l.append(number)
return l
  
listA = ask5num()
print("listaA is: ",listA)
listB = listA +[1]
print("listaB is: ",listB)

# We are allowed to answer 4 sub parts only. Please post accordingly.

Add a comment
Know the answer?
Add Answer to:
Please insert in your code the number of the question and the question itself, followed by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • Questin 1 (CO 2) Which of the following is not a valid name in python? last_name...

    Questin 1 (CO 2) Which of the following is not a valid name in python? last_name lastName last name lname Question 2 (CO 3) How many times will “Hello World” be displayed after the following code executes? num=2 while num<12:     print("Hello world")     num+=2 2 12 5 4 Question 3 (CO 1) The following code contains an error, what type of error is it and what line number is it? 1 count=1 2 while count<4 3    print("count = ",...

  • QUESTION 21 while True: , in Python, can be used to create an infinite loop. True...

    QUESTION 21 while True: , in Python, can be used to create an infinite loop. True False 2 points    QUESTION 22 The Python Framework does inform you where an error occurred True False 2 points    QUESTION 23 ____ is a critical component to being able to store data and information long term. File Access Memory Print function with 2 points    QUESTION 24 Error handling is also known as ___ handling Result Recursion Exception Crash 2 points   ...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...

  • please do it in C# language Q. 1 part 1 Create an array named weekly Temp...

    please do it in C# language Q. 1 part 1 Create an array named weekly Temp that will hold values of weekly temperatures in Fahrenheit from Monday through Sunday. Calculate the average temperature for that week and display its average. part 2 Write while loop to display the numbers from 10 through 1 and the squares. The output should display as following: squared 100 81 04 part 3 Define a method that calculates calculateareaOfCircle by passing a value of radius...

  • Python please help! Thanks you Write a code to get an unlimited number of grades from...

    Python please help! Thanks you Write a code to get an unlimited number of grades from the user (the user can press enter to finish the grades input, or use a sentinel, for example-1), and then calculate the GPA of all the grades and displays the GPA To do this you might need some help. Try to follow the following process (and check your progress by printing different values to make sure they are as they supposed to be): 1-...

  • Could anyone please help with this Python code assignment? In this programming assignment you are to...

    Could anyone please help with this Python code assignment? In this programming assignment you are to create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The count of how many numbers are in the file. The average of the numbers. The average is the sum of the numbers divided by how many there are. The maximum value. The...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super...

    Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...

  • C++ please use only easy code and stdio.h because im just a beginner Description Write the...

    C++ please use only easy code and stdio.h because im just a beginner Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT