You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importdecimalstring='12345'print(decimal.Decimal(string))
print(type(decimal.Decimal(string)))
>12345><class'decimal.Decimal'>---## 3. Reversing a String using an Extended Slicing Technique```pythonstring="Python Programming"print(string[::-1])
>gnimmargorPnohtyP
6. Counting the Number of Occurances of a Character in a String
word="python"character="p"count=0forletterinword:
ifletter==character:
count+=1print(count)
>1---## 7. Writing Fibonacci Series```pythonfib= [0,1]
# Range starts from 0 by defaultforiinrange(5):
fib.append(fib[-1] +fib[-2])
# Converting the list of integers to stringprint(', '.join(str(e) foreinfib))
>0, 1, 1, 2, 3, 5, 8