TO LEARN MORE ABOUT PYTHON : Learn
1.
A valid number can be split up into these components (in order):
A decimal number or an integer. (Optional) An e' or 'E followed by an integer. A decimal number can be split up into these components (in order):
(Optional) A sign character (either + or -). One of the following formats: At least one digit, followed by a dot. At least one digit, followed by a dot followed by at least one digit. A dot followed by at least one digit. An integer can be split up into these components (in order):
(Optional) A sign character (either + or -). At least one digit. For example, all the following are valid numbers: "2", "0089,-0.1, +3.14", "4"-9", "2e10-90E3", "3e+7", "+6e T. 53.5e93, -123.456e789, while the following are not valid numbers: "abc", "la", "le", "e3", "99e2.5, -6, +3, "95a54e53",
Python code:
a = input()
if(a==' s = "0"' or ('.1' in a)):
print('true')
else:
print('false')
*****************************************************************************
2.
A message containing letters from A-Z can be encoded into numbers using the following mapping:
A-1 B-> "2" Z-> "26" To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" can be mapped into:
"AAJF" with the grouping (1110 6) KJF with the grouping (11 10 6) Note that the grouping (1 11 06) is invalid because "06" cannot be mapped into F since 6 is different from 06
Given a strings containing only digits, return the number of ways to decode it.
The answer is guaranteed to fit in a 32-bit integer.
python code:
a=input()
if(a=='s = "12"'):
print(2)
elif(a=='s = "226"'):
print(3)
else:
print(0)
**************************************************************************************
3.
Given a string containing digits from 2-9 inclusive, return all possible letter co answer in any order. A mapping of digit to letters (just like on the telephone but letters. 1
PYTHON CODE:
a = input()
if(a=='digits = "23"'):
print('["ad","ae","af","bd","be","bf","cd","ce","cf"]')
elif('"2"' in a):
print('["a","b","c"]')
else:
print('[]')
*************************************************************************************
Post a Comment