Python Assignment 1
Python Assignment 1
Python
Assignments.
Assignment 1
1. Create a variable named carname and assign the value Volvo to it.
3. Insert the correct syntax to assign the same value to all three variables in one code line
X . Y . Z . “Sudheer”
****************
*******__*******
******____******
*****______*****
****________****
***__________***
**____________**
*______________*
5 4 3 2 1 1 2 3 4 5
5 4 3 2 2 3 4 5
5 4 3 3 4 5
5 4 4 5
5 5
Assignment 3
2. The rules for translating words from English into Pig Latin are quite simple:
1. - If the word begins with a vowel (a, e, i, o, or u), add “way” to the end of the
word. So “air” becomes “airway” and “eat” becomes “eatway.”
2. - If the word begins with any other letter, then we take the first letter, put it
on the end of the word, and then add “ay.” Thus, “python” becomes “ythonpay” and
“computer” becomes “omputercay.”
Assignment 4
1. Write a program that accepts a comma separated sequence of words as input and
prints the words in a comma-separated sequence after sorting them alphabetically.
Suppose the following input is supplied to the program:
without,hello,bag,world
Then, the output should be:
bag,hello,without,world
Example
If the following passwords are given as input to the program:
ABd1234@1,a F1#,2w3E*,2We3345
Then, the output of the program should be:
ABd1234@1
5. A robot moves in a plane starting from the original point (0,0). The robot can
move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot
movement is shown as the following:
UP 5
DOWN 3
LEFT 3
RIGHT 2
¡
The numbers after the direction are steps. Please write a program to compute the
distance from current position after a sequence of movement and original point. If
the distance is a float, then just print the nearest integer.
Example:
If the following tuples are given as input to the program:
UP 5
DOWN 3
LEFT 3
RIGHT 2
Then, the output of the program should be:
2
6. Write a program that accepts a sequence of whitespace separated words as input
and prints the words after removing all duplicate words and sorting them
alphanumerically. Suppose the following input is supplied to the program: hello
world and practice makes perfect and hello world again Then, the output should be:
again and hello makes perfect practice world