Write a function, max_value
, that takes in an integer and prints the numbers from 1 to that number inclusively.
Write a function, compare_lists
, that given two lists of numbers the same length, compares each element of the lists, and print out the higher value at each index.
list1 = [4,5,15,11,23,42]
list2 = [1,8,7,16,7,35]
compare_lists(list1, list2)
# 4 8 15 16 23 42 should print out
Write a function, swapping_stars
, that will print out the following:
* - * - * -
- * - * - *
* - * - * -
- * - * - *
* - * - * -
- * - * - *
is_even
is_int
is_int
that takes a number x
as an input.return True
if the number is an integer (as defined above) and False
otherwise.# For example
is_int(7.0) # True
is_int(7.5) # False
is_int(-1) # True
digit_sum
Write a function called digit_sum
that takes a positive integer n
as input and returns the sum of all that numberβs digits.
For example: digit_sum(1234)
should return 10
which is 1 + 2 + 3 + 4
.
(Assume that the number you are given will always be positive.)
Write a function called rectangle
. It takes two numbers as user input, and prints a rectangle.
It should look like this:
Enter width: 5
Enter height: 10
*****
*****
*****
*****
*****
*****
*****
*****
*****
*****