Programming
Python tasks
Q1.Write a python script to input and decode the following ternary numeric notation:
`x` → 0
|
`ox` → 1
|
`xx` → 2
Example input 1
xxoxx
Example input 2
xoxxoxoxxxxoxxx
Output
0012
Output
010112012
Q2.Write a Python script that takes a list of numbers and a target number as input. Sort the list using any sorting algorithm (without using any built-in sorting functions). Then, search for the target number in the sorted list and print True if it is found; otherwise, print False.
Example input 1
[7, 8, 9, 1, 7, 8, 3] 3
Example input 2
[4, 9, 3, 6, 8] 7
Output
[1, 3, 7, 7, 8, 8, 9]
True
Output
[3, 4, 6, 8, 9]
False
Q3.Write a Python script that shifts every input letter two positions forward in the alphabet while leaving all non-alphabetic characters unchanged.
Note: Letters must wrap back to a and A after z and Z respectively.
Example input 1
abcd1@
Example input 2
9A&cYzg
Output
cdef1@
Output
9C&eYbi
Q4.Write a python script that counts and prints the frequency of each character in the input string. Then print the reversed string.
Example input 1
xyzxyyzxyzza
Output
x: 3
y: 4
z: 3
a: 1
Reversed string: azzyxzyxzyx
