04-Functions-Exercise
04-Functions-Exercise
Please, submit your source code solutions for the described problems to the Judge System.
Examples
Input Output
2 2
5
3
600 123
342
123
25 4
21
4
Examples
Input Output
23 19
6
10
1 -12
17
30
42 0
58
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
3. Characters in Range
Write a function that receives two characters and returns a single string with all the characters in between them
(according to the ASCII code), separated by a single space. Print the result on the console.
Examples
Input Output
a b c
d
# $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9
:
Examples
Input Output
5. Even Numbers
Write a program that receives a sequence of numbers (integers) separated by a single space. It should print a list of
only the even numbers. Use filter().
Example
Input Output
1 2 3 4 [2, 4]
1 2 3 -1 -2 -3 [2, -2]
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Example
Input Output
6 2 4 [2, 4, 6]
Example
Input Output
8. Palindrome Integers
A palindrome is a number that reads the same backward as forward, such as 323 or 1001. Write a function that
receives a list of positive integers, separated by comma and space ", ". The function should check if each integer
is a palindrome - True or False. Print the result.
Examples
Input Output Input Output
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Hints
You can read more about palindromes here: https://en.wikipedia.org/wiki/Palindrome
9. Password Validator
Write a function that checks if a given password is valid. Password validations are:
It should be 6 - 10 (inclusive) characters long
It should consist only of letters and digits
It should have at least 2 digits
Examples
Input Output
Examples
Input Output Comments
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
28 We have a perfect 1 + 2 + 4 + 7 + 14
number!
Hint
Every perfect number is half the sum of all its positive divisors (including itself) => the sum of all positive divisors (all
of which are divided without remainder) of 6 is 1 + 2 + 3 + 6 = 12. Half of 12 is 6 => 6 is the perfect number.
You can read more about the perfect number here: https://en.wikipedia.org/wiki/Perfect_number
Examples
Input Output
30 30% [%%%.......]
Still loading...
50 50% [%%%%%.....]
Still loading...
Examples
Input Output
5 60.00
2
6 360.0
2 0
Hints
Read more about factorial here: https://en.wikipedia.org/wiki/Factorial
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.