print single digit...
1) input ..2 2 1
1) output... 1
2) input ...8 9 6 8 9 6 5
2) output...5
re-arange string in python
input.
i am 11years 8 months 5 days old
output.
i am 5 years 8 months 11 days old
salary maximum profit
input..1 11 13 21 91
Hide String
Anit is given a sentence S.He wants to create an encoding of the sentence. The encoding works by replacing each letter with its previous letter as shown in the below table. Help Anil encode the
sentence.
Letter
Previous Letter
A
B
A
Note: Consider upper and lower case letters as different.
Input
The first line of input is a string S
New Dictionary
Peter is making a new dictionary. He wants to arrange the words in the ascending order of their length and later arrange the ones with the same length in lexicographic order. Each word is given a serial number according to its position. Find the word according to the serial number.
The serial number of words in Peter's dictionary is as follows
Word
Serial Number
A
B
1.
C
24
25
26
27
AA
AB
28
BA
2. Give at least three examples that show different features of string slices. Describe the feature illustrated by each example. Invent your own examples.
1. Consider the loop from Section 8.3 of your textbook.
prefixes = 'JKLMNOPQ'
suffix = 'ack'
for letter in prefixes:
print(letter + suffix)
Put this code into a Python script and run it. Notice that it prints the names "Oack" and "Qack".
Modify the program so that it prints "Ouack" and "Quack" but leaves the other names the same.
Include the modified Python code and the output in your submission.
Provide your own examples of the following using Python lists. Create your own examples. Do not copy them from another source.
Nested lists
The “*” operator
List slices
The “+=” operator
A list filter
A list operation that is legal but does the "wrong" thing, not what the programmer expects
Provide the Python code and output for your program and all your examples.
Write a Python program that does the following.
Create a string that is a long series of words separated by spaces. The string is your own creative choice. It can be names, favorite foods, animals, anything. Just make it up yourself.
Turn the string into a list of words using split.
Delete three words from the list, but delete each one using a different kind of Python operation.
Sort the list.
Add new words to the list (three or more) using three different kinds of Python operation.
Turn the list of words back into a single string using join.
Print the string.
Describe the difference between objects and values using the terms “equivalent” and “identical”. Illustrate the difference using your own examples with Python lists and the “is” operator.
Describe the relationship between objects, references, and aliasing. Again, create your own examples with Python lists.
Finally, create your own example of a function that modifies a list passed in as an argument. Describe what your function does in terms of arguments, parameters, objects, and references.
Create your own unique examples for this assignment.