1.House Password--------------------------------------------- ----------------------------------------
Input: A password as a string.
Output: Is the password safe or not as a boolean or any data type that can be converted and processed as a boolean. In the results you will see the converted results.
Example:
checkio('A1213pokl') == False
checkio('bAse730onE') == True
checkio('asasasasasasasaas') == False
checkio('QWERTYqwerty') == False
checkio('123456123456') == False
checkio('QwErTy911poqqqq') == True
def checkio(data):
if len(data)>=10:
if not(data.isdigit() or data.isalpha() or data.islower() or data.isupper()):
return True
return False
2.The Most Wanted Letter-------------------------------------------- ---------------------------------------
If you have two or more letters with the same frequency, then return the letter which comes first in the latin alphabet. For example -- "one" contains "o", "n", "e" only once for each, thus we choose "e".
Input: A text for analysis as a string.
Output: The most frequent letter in lower case as a string.
Example:
checkio("Hello World!") == "l"
checkio("How do you do?") == "o"
checkio("One") == "e"
checkio("Oops!") == "o"
checkio("AAaooo!!!!") == "a"
checkio("abe") == "a"
def checkio(text):
lower_text = text.lower()
appear_time = {}
for each in lower_text:
if each.islower():
if each not in appear_time:
appear_time[each] = 0
else:
appear_time[each] += 1
array = list(appear_time.items())
array.sort(key=lambda x:x[0])
array.sort(key=lambda x:x[1], reverse=True)
return array[0][0]
3.Non-unique Elements-------------------------------------------- -------------------------------------
You are given a non-empty list of integers (X). For this task, you should return a list consisting of only the non-unique elements in this list. To do so you will need to remove all unique elements (elements which are contained in a given list only once). When solving this task, do not change the order of the list. Example: [1, 2, 3, 1, 3] 1 and 3 non-unique elements and result will be [1, 3, 1, 3].
non-unique-elements
Input: A list of integers.
Output: The list of integers.
Example:
checkio([1, 2, 3, 1, 3]) == [1, 3, 1, 3]
checkio([1, 2, 3, 4, 5]) == []
checkio([5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5]
checkio([10, 9, 10, 10, 9, 8]) == [10, 9, 10, 10, 9]
def checkio(data):
#Your code here```
#It's main function. Don't remove this function
#It's used for auto-testing and must return a result for check.
#replace this for solution
list2=[]
for num in data:
count=data.count(num)
if count>=2:
list2.append(num)
else:pass
return list2
4.Mokey Typing---------------------------------------------- ------------------------------------
You are given some text potentially including sensible words. You should count how many words are included in the given text. A word should be whole and may be a part of other word. Text letter case does not matter. Words are given in lowercase and don't repeat. If a word appears several times in the text, it should be counted only once.
For example, text - "How aresjfhdskfhskd you?", words - ("how", "are", "you", "hello"). The result will be 3.
Input: Two arguments. A text as a string (unicode for py2) and words as a set of strings (unicode for py2).
Output: The number of words in the text as an integer.
Example:
count_words("How aresjfhdskfhskd you?", {"how", "are", "you", "hello"}) == 3
count_words("Bananas, give me bananas!!!", {"banana", "bananas"}) == 2
count_words("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
{"sum", "hamlet", "infinity", "anything"}) == 1
def count_words(text, words):
text=text.lower()
count=0
for word in words:
if word in text:
count+=1
return count