Rearrange Numbers in String
Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part.
The input will be a single line containing a string.
The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order.
For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".
Sample Input
I am 5 years and 11 months old
Sample Output
I am 11 years and 5 months old
Sample Input
python4 anjali25
Sample Output
python25 anjali4
Sample Input
1python254
Sample Output
254python1
Sample Input
-1pyth-4on 5lear-3ning-2
Sample Output
5pyth4on 3lear2ning1
Rearrange Numbers in String
Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part.
Input
The input will be a single line containing a string.
Output
The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order.
Explanation
For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".
Sample Input 1
I am 5 years and 11 months old
Sample Output 1
I am 11 years and 5 months old
Sample Input 1
Exam2 will be held on 1st week of august20
Sample Output 1
Exam20 will be held on 2st week of august1
Strings are immutable, meaning they can’t be modified. In this lesson, you’ll learn how to accomplish changing strings by generating a copy of the original string instead:
>>>
>>> s = 'mybacon'
>>> s[2] = 'f'
Traceback [most recent call last]:
File "", line 1, in
s[2] = 'f'
TypeError: 'str' object does not support item assignment
Here’s how to copy a string:
>>>
>>> s = 'mybacon'
>>> s = s[:2] + 'f' + s[3:]
>>> s
'myfacon'
>>> s = 'mybacon'
>>> s = s.replace['b', 'f']
>>> s
'myfacon'
Assignment QuestionSet 1Question[1]Write a program to draw and fill the following pattern using *: [10]a.b.Question[2]Write a program to find the prime number with in the given range of values.[10]Question[3]Write a program to take the personal and academic information input fromcandidate and display output in the format shown below.[10]
Set 2Question[1]Write a Python function that takes a sequence of numbers and determineswhether all the numbers are different from each other.[10]Question[2]Write a Python program to create all possible strings by using 'a', 'b', 'c','d', 'e'. Use the characters exactly once.[10]Question[3]Write a program to draw and fill the following pattern using *:[10]Set 3Question[1]Write a Python program to create all possible strings by using 'o', 'p', 'q', 'r','s'. Use the characters exactly once.[10]Question[2]Write a Program to draw and fill the following pattern using *:[10]
Question[3]Write a Python program to get all possible two digit letter combinationsfrom a digit [1 to 9] string.[10]string_maps = {"1": "zyx","2": "wvu","3": "tsr","4": "qpo","5": "nml","6": "kji","7": "hgf","8": "edc","9": "ba"}Set 4Question[1]Write a Python program to check the sum of three elements [each from anarray] from three arrays is equal to one less than target value. Print all those three-element combinations.[10]
Get answer to your question and much more
Question[2]Write a Python program that accept a positive number and subtract fromthis number the product of its digits and so on. Continues this operation until the numberis positive.[10]Question[3]Write a program to draw and fill the following pattern using *:[10]Set 5Question[1]Write a Python program to find the digits which are absent in a givenmobile number.Question[2]Write a Python program to find the number of zeros at the end of afactorial of a given positive number.Range of the number[n]: [1 = n = 2*109].Question[3]Write a Python program that reads n digits [given] chosen from 0 to 9 andprints the number of combinations where the sum of the digits equals to another givennumber [s]. Do not use the same digits in a combination.Input:Two integers as number of combinations and their sum by a single space in a line. Input 0 0to exit.Input number of combinations and sum, input 0 0 to exit:5 62 40 02
SET- 61.Create a python function ‘assign_grade[list]’ which records the marks of ten students froma list and assign a grade based on the following conditions:If marks>=90 then grade AIf marks >=80 &&65 &&=40 &&