In: Computer Science
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!
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