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

Write a code that reads a number from the user and prints backwards from the number to 1. Use a loop to solve the problem.
Write a code to find out the sum of the sequence 2 -4 6 -8 10 -12... While the last value will be determined from input. Use a loop to solve the problem.
Write a code to find out the sum of the sequence 2 -4 6 -8 10 -12.... while the last value will be determined from input. Use a loop to solve the problem.
Write a code to iterate through your name by taking input and print each letter in uppercase using loop. This should work if every letter of your name is in lowercase

Sample Input: sakib

Sample Output: S A K I B

Hint: You can convert a letter to uppercase using the function upper(). If your character, c = "j", use c.upper() to convert it to "J"
Write a python program using For loop that reads a number from the user and prints the multiplication table of that number [Upto 10].
Write a code to print multiples of 3 or 7 from 1 to 100 using while loops.
Write a python program that takes 10 inputs from the user, and then prints how many inputs are odd and how many inputs are even. Use for loop.

Sample input:

2

6

8

3

9

2

6

4

3

7

Sample Output:

Even numbers = 6, Odd numbers = 4
Write a python program that takes a number from the user. If the number is odd, print that many "*" and if the number is even, print that many "+" as output. Use for loop.

Example 1

Sample input: 5

Sample Output: *****

Example 2

Sample input: 10

Sample Output: ++++++++++
Write a python program that takes an input from the user and then prints numbers starting from 1 to the given input. The output should be in one line. Use while loop.

Example 1

Sample Input: 10

Sample Output: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Example 2

Sample Input: 5

Sample Output: 1, 2, 3, 4, 5
Armstrong numbers between two intervals

Write a program to print all the Armstrong numbers in the given range 

A to B(including A and B). An N-digit number is an Armstrong number if the number equals the sum of the Nth power of its digits.

Input

The first line has an integer 

A. The second line has an integer B.

Output

Print all Armstrong numbers separated by a space.
If there are no Armstrong numbers in the given range, print 

-1.

Explanation

For 

A = 150 and B = 200

For example, if we take number 153, the sum of the cube of digits 

1, 5, 3 is

 13 + 53 + 33 = 153.

So, the output should be 

153.

Sample Input 1
150
200
Sample Output 1
153
Sample Input 2
1
3
Sample Output 2
1 2 3

sample input3 
10
15
sample output 3
-1

please provide correct output in sample output 2
LATEST TUTORIALS
APPROVED BY CLIENTS