Question

In: Computer Science

solve with python 3.8 please 1,Write a function called make_squares_coordinate_pair that has one parameter - an...

solve with python 3.8 please

1,Write a function called make_squares_coordinate_pair that has one parameter - an int. The function should return a tuple containing that int and its square. Suppose you

were to call your function like this:

print(make_squares_coordinate_pair(5))

This should output:

(5, 25)

Your function MUST be called make_squares_coordinate_pair. You can write code in the main part of your program to test your function, but when you submit, your code must ONLY have the function definition!

2,

Write a function called add_coordinates that has two tuple parameters. It should assume each tuple has two ints. It should return a tuple of size two that is the sum of the two tuples it was given. In other words, the 0th item in the returned tuple should be the sum of the 0th items in the parameter tuples, and the 1st item in the returned tuple should be the sum of the 1st items in the parameter tuples.

Suppose you call your function like this:

print(add_coordinates((2, 3), (-3, 4)))

This should output:

(-1, 7)

Your function MUST still be called add_coordinates. You can write code in the main part of your program to test your function, but when you submit, your code must ONLY have the function definition!

3,

Write a function called print_positive_multiples that takes two int parameters. It prints positive multiples of the first parameter. The second parameter determines how many multiples are printed. If you call your function with 4 and 5 as arguments, your function should print the first 5 positive multiples of 4, like this:

4
8
12
16
20

Your function MUST be called print_positive_multiples. You can write code in the main part of your program to test your function, but when you submit, your code must ONLY have the function definition!

Solutions

Expert Solution

1 code:-

def make_squares_coordinate_pair(n): 
    sum=n*n
    return n, sum;  
print(make_squares_coordinate_pair(5))

output:-

(5,25)

2 code:-

def add_coordinates(a,b):
    c=[0,0]
    c[0]=a[0]+b[0];
    c[1]=a[1]+b[1];
    return tuple(c)
print(add_coordinates((2, 3),(-3, 4)))

output:-

(-1,7)

3 code:-

def print_positive_multiples(n,m):
    for i in range(1,m+1):
         print(n*i)
print_positive_multiples(4,5)
        

output:-

4                                                                                                                                                             
8                                                                                                                                                             
12                                                                                                                                                            
16                                                                                                                                                            
20   


Related Solutions

Python Programming 1. Write a function name split_name which takes one parameter called name. If the...
Python Programming 1. Write a function name split_name which takes one parameter called name. If the name parameter value is a name in the form LastName, FirstName(e.g., ”Grounds, Nic”) then the function should return a list of two elements where FirstName is the first element and LastName is the second element. If the name parameter value is a name in the form FirstName LastName(e.g., ”Nic Grounds”) then the function should return a list of two elements where FirstName is the...
using python 1. #Write a function called multiply_by_index. multiply_by_index #should have one parameter, a list; you...
using python 1. #Write a function called multiply_by_index. multiply_by_index #should have one parameter, a list; you may assume every item #in the list will be an integer. multiply_by_index should #return a list where each number in the original list is #multipled by the index at which it appeared. # #For example: # #multiply_by_index([1, 2, 3, 4, 5]) -> [0, 2, 6, 12, 20] # #In the example above, the numbers 1, 2, 3, 4, and 5 appear #at indices 0,...
Python program. Write a function called cleanLowerWord that receives a string as a parameter and returns...
Python program. Write a function called cleanLowerWord that receives a string as a parameter and returns a new string that is a copy of the parameter where all the lowercase letters are kept as such, uppercase letters are converted to lowercase, and everything else is deleted. For example, the function call cleanLowerWord("Hello, User 15!") should return the string "hellouser". For this, you can start by copying the following functions discussed in class into your file: # Checks if ch is...
use python to solve Write a function called word_chain that repeatedly asks the user for a...
use python to solve Write a function called word_chain that repeatedly asks the user for a word until either (1) the user has entered ten words, or (2) the user types nothing and presses enter. Each time the user enters an actual word, your program should print all the words entered so far, in one long chain. For example, if the user just typed "orange", and the user has already entered "apple" and "banana", your program should print "applebananaorange" before...
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the...
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the #file and return the contents.# # # - If the contents of the file can be interpreted as # an integer, return the contents as an integer. # - Otherwise, if the contents of the file can be # interpreted as a float, return the contents as a # float. # - Otherwise, return the contents of the file as a # string. #...
In python please write the following code the problem. Write a function called play_round that simulates...
In python please write the following code the problem. Write a function called play_round that simulates two people drawing cards and comparing their values. High card wins. In the case of a tie, draw more cards. Repeat until someone wins the round. The function has two parameters: the name of player 1 and the name of player 2. It returns a string with format '<winning player name> wins!'. For instance, if the winning player is named Rocket, return 'Rocket wins!'.
In C: Write a function definition called PhoneType that takes one character argument/parameter called phone and...
In C: Write a function definition called PhoneType that takes one character argument/parameter called phone and returns a double. When the variable argument phone contains the character a or A print the word Apple and return 1099.99 When phone contains anything else return a 0.0
#Write a function called find_max_sales. find_max_sales will #have one parameter: a list of tuples. Each tuple...
#Write a function called find_max_sales. find_max_sales will #have one parameter: a list of tuples. Each tuple in the #list will have two items: a string and an integer. The #string will represent the name of a movie, and the integer #will represent that movie's total ticket sales (in millions #of dollars). # #The function should return the movie from the list that #had the most sales. Return only the movie name, not the #full tuple. #Below are some lines of...
In Python Create a function called ℎ?????. The function has as arguments a list called ??????...
In Python Create a function called ℎ?????. The function has as arguments a list called ?????? and a list call center. • List ?????? contains lists that represent points. o For example, if ?????? = [[4,2], [3,2], [6,1]], the list [4,2] represents the point with coordinate ? at 4 and y coordinate at 2, and so on for the other lists. Assume that all lists within points contain two numbers (that is, they have x, y coordinates). • List ??????...
'PYTHON' 1. Write a function called compute_discount which takes a float as the cost and a...
'PYTHON' 1. Write a function called compute_discount which takes a float as the cost and a Boolean value to indicate membership. If the customer is a member, give him/her a 10% discount. If the customer is not a member, she/he will not receive a discount. Give all customers a 5% discount, since it is Cyber Tuesday. Return the discounted cost. Do not prompt the user for input or print within the compute_discount function. Call the function from within main() and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT