CSE 1310 - Assignments

Not Graded Practice for Assignment 3


Exercise 1.

From the following list:
list1 = ['hello', 'hallo', 'hola', 'konnichiwa', 'bonjour', 'ciao'],

create a new list (list2) by only adding the elements of list1 in even positions. For example the resulting list will contain:

list2 = ['hallo', 'konnichiwa', 'ciao'].

Exercise 2.

Create a program in python that finds the first occurrence (if any) of a vowel in a word.
Example:

 Input: Bazinga!
 Output: "a" was detected in the list at position 2.

Exercise 3.

Given a list of integers, write a program that partitions this list onto two lists one for odd numbers and the other for even ones.
Example:

Input: [-5, 7, 2, 3, 6, 10, -8, 7, 0]

Output: 
list_odd = [-5, 7, 3, 7]
list_even = [2, 6, 10, -8, 0]


Exercise 4.

Write a program that remove any punctuation marks (-,:;!".?) from a sentence.
Example:

Input: Minds- are: like parachutes? They. "only; function~ when they are open!.

Output: Minds are like parachutes They only function when they are open


Exercise 5.

Write a program, in which the user inputs a sentence, that makes a sorted list of unique letters used in the sentence. No punctuation or spaces should appear on the list.
Example:

Input: -Try not to become a man of success, but rather, try to become a man of value!

Output: 
t = 7, o = 7, e = 7, 
a = 6, 
m = 4, 
n = 3, b = 3, s = 3, u = 3, c = 3
r = 2, y = 2 f = 2, 
h = 1, v = 1, l = 1.

Exercise 6.

Palindrome is a word that can be read the same from left to right as from right to left. For example, 'Racecar' is a palindrome.

Write a program, in which the user enters any word, and the program displays if the entered word is a palindrome or not.


Exercise 7.

In Python, every character can be converted to an integer (which is called the "ASCII code" of the character), using the ord function. For example, ord('a') returns 97.

Similarly, an ASCII code can be converted to a character using the chr function. For example, chr(97) returns 'a'.

The following string:

Message = 'Uijt!jt!uif!tpmvujpo!up!fyfsdjtf!8"'

has been encrypted with the Caesar's cipher encryption algorithm, i.e. by shifting of +1 each given character from the original (unencrypted) string in the ASCII table.
For example, the string:

'Attack!'

would be encrypted as:

'Buubdl"'

Write a Python program that decrypts the given string Message and prints the solution on the screen. The code must be at maximum 6 lines of code.