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,...
(C++) In a file called pp7c.cpp, write a function called printMoney that has one parameter, a...
(C++) In a file called pp7c.cpp, write a function called printMoney that has one parameter, a double, and it prints this parameter out formatted like a dollar amount with $ and exactly 2 digits to the right of the decimal. Write a driver that declares an array of monetary amounts like this: double amounts[MAX_AMOUNTS]; and uses a while or do while loop to ask the user for monetary amounts with -1 for the amount as a sentinel value to put...
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...
Write a python program that has: function createCustomerRecord that has 1 parameter, the filename to read...
Write a python program that has: function createCustomerRecord that has 1 parameter, the filename to read from, the method then reads all the records from the file and returns a dictionary. Each record in the file has the following format CivilIdNumber Name Telephone#     Address CivilIdNumber Name Telephone#     Address CivilIdNumber Name Telephone#     Address Etc A record always consists of 4 lines (civilid, name, telephone and address). You can find a sample input file on last page of this assignment, copy it...
- Write a function with a parameter called A (which is between 1 and 10) and...
- Write a function with a parameter called A (which is between 1 and 10) and prints the multiplication table for 1 to A. • Note: Do not need to draw the horizontal and vertical lines. • Example for A = 10.
#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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT