Python Answers

Questions answered by Experts: 5 288

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Create a Python script which will accept a positive integer and will display the DIVISORS of the input number.


Sample Output:

Input a Positive Integer : 20

The DIVISORS of 20 are...

1 2 4 5 10 20


I need the code to have an output stated above.


Create a Python script which will accept a positive integer (n) and any character then it will display the input character n times.

Sample Output:

Positive Integer (n) : 7 Input any Character : A AAAAAAA


I need the code to have an output stated above.


print multiples of 3 in given N numbers


print 9 number with help of "*"


Create a Python script which will accept two positive integers where the first number would be the start of a range and the second number would be the end of a range. Then the application will determine the sum of all EVEN numbers and sum of all ODD numbers from the given range.


Sample Output:

Start of a Range: 5

End of a Range: 10

Sum of Even nos. is 24

Sum of Odd nos. is 21


I need the code to have an output stated above.


Write a python function that accepts a list of numbers and try to find out the value of a ‘magic index’. The ‘magic index’ is calculated as the ratio of the largest and smallest list element. The python function Magic_Index(A) (Refer RollNo_W10B_1.py)Take a list of elements and return the value of the magic index or error message for any possible exceptions. The error message will be "error occurred = error name".

Given a string in camel case, write a python program to convert the given string from camel case to snake case

Write a python program that prints a rectangle of size M (height/line numbers) and N (length/column numbers) using incrementing numbers where M and N will be given as input. Please look at the examples below for clarification.



How do I remove the extra "And" when I input 2 and 3 flavors? When I input, "Chocolate Vanilla" I don't get extra "And" but when I include, "Chocolate and Vanilla", I get the extra "And". 


Example: You have selected Chocolate and Vanilla flavors!

My Incorrect Output: You have selected Chocolate And and Vanilla flavors!


order = input("\n" + first_name.capitalize() + "," " " + "Which flavors would you like on your icecream today?\n\n" +
              "\n".join(["Chocolate", "Vanilla", "Strawberry"]) + "\n\n")

order = order.lower().split()
plural = "s" + "!" if len(order) > 1 else "" "!"
union = " and " if len(order) > 1 else ""
print("\nYou have selected" + " " + ", " .join(order[:-1]).title() + union + order[-1].title() + " " + "flavor" + plural)

Number Arrangement

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 is a string containing the actual sentence.


Output

The output is a string containing the modified sentence as mentioned above.


Explanation

For example, if the actual sentence is It is a 3days 4nights holiday trip.

The numbers in the sentence are 3 and 4.After arranging them in the decreasing order, the output looks like It is a 4days 3nights holiday trip.


Sample Input1

It is a 3days 4nights holiday trip

Sample Output1

It is a 4days 3nights holiday trip



LATEST TUTORIALS
APPROVED BY CLIENTS