Ejercicios en clases funciones Python
Ejercicios en clases funciones Python
1. Create a function that takes 2 integers in form of a string as an input, and outputs the sum (also as
a string):
2. Find the difference between two collections. The difference means that either the character is
present in one collection or it is present in other, but not in both. Return a sorted list with the
difference.
The collections can contain any character and can contain duplicates.
Example:
A = [a, a, t, e, f, i, j]
B = [t, g, g, i, k, f]
difference = [a, e, g, j, k]
3. Given two integers a and b, which can be positive or negative, find the sum of all the integers
between and including them and return it. If the two numbers are equal return a or b.
(1, 0) --> 1 (1 + 0 = 1)
(1, 2) --> 3 (1 + 2 = 3)
(0, 1) --> 1 (0 + 1 = 1)
(1, 1) --> 1 (1 since both are same)
(-1, 0) --> -1 (-1 + 0 = -1)
(-1, 2) --> 2 (-1 + 0 + 1 + 2 = 2)
Your function should only return a number, not the explanation about how you get that number.
4. Write a function get_number_of_squares(n) that will return how many integer (starting from 1,
2...) numbers raised to power of 2 and then summed up are less than some number given as a
parameter.
Example:
x = 16
6. Check to see if a string has the same amount of 'x's and 'o's. The method must return a boolean
and be case insensitive. The string can contain any char.
Examples input/output: