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

Sovle with python 3.8 please. 1, Write a function called same_without_ends that has two string parameters....
Sovle with python 3.8 please. 1, Write a function called same_without_ends that has two string parameters. It should return True if those strings are equal WITHOUT considering the characters on the ends (the beginning character and the last character). It should return False otherwise. For example, "last" and "bask" would be considered equal without considering the characters on the ends. Don't worry about the case where the strings have fewer than three characters. Your function MUST be called same_without_ends. You...
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,...
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and...
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and returns a new sequence that is twice the length of the parameter sequence but that contains the contents of the original in palindrome form. For example, if the sequence "super" is passed into the function, the function will return "superrepus".
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. #...
Please write the code in c++ Write a function with one input parameter that is a...
Please write the code in c++ Write a function with one input parameter that is a vector of strings. The function should count and return the number of strings in the vector that have either an 'x' or a 'z' character in them. For example, when the function is called, if the vector argument contains the 6 string values, "enter", "exit", "zebra", "tiger", "pizza", "zootaxy" the function should return a count of 4. ("exit", "zebra", "pizza", and "zootaxy" all have...
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
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!'.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT