# Programming project 1 Solution

\$30.00 \$24.00

Quantity

## Description

1. Write a Python program to find the first repeated character in a given string. Ex. Input string: badabe, output: a

1. Write a Python program to print the vowels, a,e,i,o,u, occurring in a given text and their total number.

1. Write a Python program to concatenate two given strings after removing the first two characters of each string.

1. A permutation p of n symbols is an ordered list of n symbols (no repetitions). For example, p=cefdab is a permutation of length 6 on the symbols a,b,c,d,e,f. Write a Python program that reads a string representing a permutation on n symbols and prints the index (position) of each character in the string.

Ex. Input string=cdaefb ; output: pos(a) = 3; pos(b) = 6; pos(c) = 1; pos(d) = 2; pos(e)= 4; pos(f )= 5.

1. Write a Python program that reads a list representing a permutation on a given set of characters (for instance a,b,c,d,e,f) and prints the index (position) of each character in the string. Same as problem 4. except that the data structure is a list of characters.

Ex. Input: [c,d,a,e,f,b]; output: pos(a) = 3; pos(b) = 6; pos(c) = 1; pos(d) = 2; pos(e)= 4; pos(f )= 5.

1. Write a Python program that reads two lists and then calls a function that takes the two lists and returns True if they have at least one common member.

Ex. Input: string1=cdaefb string2=xyzea; output: TRUE

As a comment in your code write the time complexity of your algorithm as a function of the lengths n and m of the two lists

1. Write a Python program to exchange the position of every n-th value, n odd, with the (n+1)th in a list.

Ex. Input list: [0,1,2,3,4,5] Output: [1, 0, 3, 2, 5, 4]

1. Write a Python program to construct and print a 10 ×10 matrix [ , ] of integers such as [ , ] = ∗ . In the output every row is on a separate line

1. Write a Python program that constructs two 10 ×10 matrices M and N of integers, selected at random in the range [0,20]. It then computes and prints the matrix C which is the difference of M and N, i.e. [ , ] = [ , ] − [ , ].

0