Examly Python Code Output
Examly Python Code Output
width = 6
fill_char = "#"
s = str(num)
print(s.rjust(width, fill_char))
Output:
###23
##456
#7890
#####5
code = "PROD-1234"
Output:
True
3. Hyphen to camelCase:
s = "this-is-a-test"
parts = s.split("-")
print(camel)
Output:
thisIsATest
4. Validate filename:
filename = "document123.txt"
True
5. Remove punctuation:
import string
print(clean)
Output:
word = "position"
print(sentence.find(word), sentence.index(word))
Output:
9 9
7. Generate username:
first = "john"
last = "doe"
num = "101"
print(username)
Output:
john_doe_101
print(count)
Output:
10
s = "abcdefghij"
n = 3
print(chunks)
Output:
width = 20
print(line.center(width))
Output:
Hello
World
in
Python
width = 10
print(row[0].ljust(width) + row[1].rjust(width))
Output:
Name Marks
Alice 85
Bob 90
genre = "Fantasy"
Output:
True
words = text.split()
Output:
Words: 5 Numbers: 2
result = []
start = s.find('"')
if end == -1:
break
result.append(s[start+1:end])
print(result)
Output:
['hello', 'bye']
15. Extract numbers from text:
print(nums)
Output:
vowels = "aeiouAEIOU"
print(count)
Output:
password = "abc123"
Output:
True
s = "abc12345def678gh"
import re
matches = re.findall(r'\d+', s)
print(longest)
Output:
12345
if len(words) == 1:
print(words[0])
else:
Output:
word = "python"
print(para.lower().count(word.lower()))
Output: