Question

In: Computer Science

Q.1: create a python function that takes two integers from the user ( pass them from...

Q.1: create a python function that takes two integers from the user ( pass them from the main program). The function performs the addition operation and returns the result. In the program, ask the user to guess the result. Then, the program compares the user input ( guess) with the returned value, and displays a message that tells if the user guessing is correct or not.

--define the function here ---

# the program starts here

print(“ This program tests your knowledge of the addition operation:”)

number1, number2 =input (“ Enter two numbers: “). ????? # complete the input statement by replacing #????

theNumber1 =int(number1)

theNumber2 =int(number2)

guess = float(input(“Enter your guess of adding the two numbers: “))

---call the function---

---- compare here-----

---- display the message-----

create a python function (only) that generates 10 random numbers within a specific range. Every time a number is generated, it is appended to a list (you need to initialize a list). Then the function counts how many times a number is repeated in the created list (you can choose any number to count). The function returns the list, the number you have chosen and its count.

--define the function here ---

Call the following function twice by passing a tuple of int and tuple of float:

def average(*args):

return sum(args) / len(args)

Solutions

Expert Solution

Code and output

Code fot copying

def addition(theNumber1,theNumber2):
c=theNumber1+theNumber2
return c
print("This program tests your knowledge of the addition operation")
number1, number2 =input ("Enter two numbers: ").split(' ')
theNumber1 =int(number1)
theNumber2 =int(number2)
guess = float(input("Enter your guess of adding the two numbers: "))
print("The addition of two numbers is {}".format(addition(theNumber1,theNumber2)))
if addition(theNumber1,theNumber2)==guess:
print("Your guess is correct")
if addition(theNumber1,theNumber2)!=guess:
print("Your guess is not correct")

Code snippet

def addition(theNumber1,theNumber2):
    c=theNumber1+theNumber2
    return c
print("This program tests your knowledge of the addition operation")
number1, number2 =input ("Enter two numbers: ").split(' ')
theNumber1 =int(number1)
theNumber2 =int(number2)
guess = float(input("Enter your guess of adding the two numbers: "))
print("The addition of two numbers is {}".format(addition(theNumber1,theNumber2)))
if addition(theNumber1,theNumber2)==guess:
    print("Your guess is correct")
if addition(theNumber1,theNumber2)!=guess:
    print("Your guess is not correct")


Related Solutions

python practice! 1. Create a function that takes a user choice and one number as parameters...
python practice! 1. Create a function that takes a user choice and one number as parameters and returns the operation result. -Square: print the number square -Sqrt: print the square root of the number -Reverse: reverse the sign of the number (pos or neg) and print it Note: Detect invalid choices and throw an error message – Number can be anything. 2. Create a function that takes a user choice and two numbers (start and end) as parameters. For example,...
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
USING PYTHON, write a function that takes a list of integers as input and returns a...
USING PYTHON, write a function that takes a list of integers as input and returns a list with only the even numbers in descending order (Largest to smallest) Example: Input list: [1,6,3,8,2,5] List returned: [8, 6, 2]. DO NOT use any special or built in functions like append, reverse etc.
In C++, create a function exchangesl that takes an argument of an array of integers (...
In C++, create a function exchangesl that takes an argument of an array of integers ( for C++ use implement void exchangesl(vector<int>& a) . Those integers need to be changed so that the smallest and largest values in the array are exchanged. Assume that there is at least one element, if the largest value occurs more than once then exchange the first instance, if the smallest value happens more than once then exchange the last instance.
In C++, create a function exchangesl that takes an argument of an array of integers (...
In C++, create a function exchangesl that takes an argument of an array of integers ( for C++ use implement void exchangesl(vector<int>& a) . Those integers need to be changed so that the smallest and largest values in the array are exchanged. Assume that there is at least one element, if the largest value occurs more than once then exchange the first instance, if the smallest value happens more than once then exchange the last instance. Use the following file:...
In python I want to create a singular function that takes two parameters 'head; and 'skip'....
In python I want to create a singular function that takes two parameters 'head; and 'skip'. Head is a linked list. Skip is a non negative value. If skip is zero it should return the linked list unchanged. The skip amount determines the amount to skip over. I want to change the linked list accordingly and then return the linked list with the modifications, not a list. If you have a linked list 11 -> 12 -> 18 -> 20...
In python I want to create a singular function that takes two parameters 'head; and 'skip'....
In python I want to create a singular function that takes two parameters 'head; and 'skip'. Head is a linked list. Skip is a non negative value. If skip is zero it should return head unchanged. The skip amount determines the amount to skip over. I want to change the linked list accordingly. If you have a linked list 11 -> 12 -> 18 -> 20 -> 24 -> 32 -> 38 -> 44 and skip =2, then you should...
Create a Python program that will take an unsorted list of 1000 integers and sort them...
Create a Python program that will take an unsorted list of 1000 integers and sort them using a bubble sort and an insertion sort. Your output should include displaying both sorted lists (from each algorithm) identifying each sorted list by the algorithm used.
1. Write a python program to create a list of integers using random function. Use map...
1. Write a python program to create a list of integers using random function. Use map function to process the list on the expression: 3x2+4x+5 and store the mapped elements in another list. Now use filter to do sum of all the elements in another list. 2. Write a function that takes n as input and creates a list of n lists such that ith list contains first 10 multiples of i. 3. Write a function that takes a number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT