Questions: 5 831

Answers by our Experts: 5 728

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 & Filtering

Sum of K powers

Write a program to print the sum of the Kth power of the first N natural numbers.

Input

The first line of input is an integer N. The second line of input is an integer K.

Explanation

In the given example, the sum of first

5 natural numbers power of 3.The sum should be 13 + 23 + 33 + 43 + 53

Therefore, the output should be

225.

Sample Input 1

5

3

Sample Output 1

225

Sample Input 2

2

8

Sample Output 2

257




Diamond Crystal

Given an integer value 

N, write a program to print a diamond pattern of 2*N rows as shown below.

Input

The first line of input is an integer 

N.

Explanation

In the given example, the number of rows in the diamond is 

2*5 = 10.

So, the output should be

    /\
   /  \
  /    \
 /      \
/        \
\        /
 \      /
  \    /
   \  / 
    \/
Sample Input 1
5
Sample Output 1
    /\
   /  \
  /    \
 /      \
/        \
\        /
 \      /
  \    /
   \  /
    \/
Sample Input 2
3
Sample Output 2
  /\
 /  \
/    \
\    /
 \  /
  \/

please provide correct output
Diamond

Given an integer value 

N, write a program to print a number diamond of 2*N -1 rows as shown below.

Input

The first line of input is an integer 

N.

Explanation

In the given example, the number of rows in the diamond is 

5.

So, the output should be

. . . . 0 . . . . 
. . . 0 0 0 . . . 
. . 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0
. 0 0 0 0 0 0 0 . 
. . 0 0 0 0 0 . . 
. . . 0 0 0 . . . 
. . . . 0 . . . .
Sample Input 1
5
Sample Output 1
. . . . 0 . . . . 
. . . 0 0 0 . . . 
. . 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0 
. 0 0 0 0 0 0 0 . 
. . 0 0 0 0 0 . . 
. . . 0 0 0 . . . 
. . . . 0 . . . .
Sample Input 2
4
Sample Output 2
. . . 0 . . . 
. . 0 0 0 . . 
. 0 0 0 0 0 . 
0 0 0 0 0 0 0 
. 0 0 0 0 0 . 
. . 0 0 0 . . 
. . . 0 . . .

please provide correct output 
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

please provide correct output in sample output 2
Shaded Diamond

Given an integer value 

N as input, write a program to print a shaded diamond of 2*N -1 rows using an asterisk(*) character as shown below.

Note: There is a space after each asterisk (*) character.

Input

The first line of input is an integer 

N.

Explanation

In the given example 

N = 5. Therefore, the output should be

    * 
   * * 
  * * * 
 * * * * 
* * * * * 
 *     *
  *   *
   * *
    *
Sample Input 1
6
Sample Output 1
     * 
    * * 
   * * * 
  * * * * 
 * * * * * 
* * * * * * 
 *       *
  *     *
   *   *
    * *
     *
Sample Input 2
5
Sample Output 2
    * 
   * * 
  * * * 
 * * * * 
* * * * * 
 *     *
  *   *
   * *
    *

please provide correct output

# Method: Append a new price level to the levelsList

def addLevel(self):

try:

# Let the user enter a new float value and append it to the list

...

except:

# Print and error message if the user entered invalid input

...

# Method: Remove an existing price level from the levelsList

def removeLevel(self):

try:

# Let the user enter a new float value. If found in the list, remove it from the list

...

except:

# Print and error message if the user entered invalid input

...

# Method: Set levelsList to an empty list

def removeAllLevels(self):

# Set levelsList to an empty list

...

Replace ellipsis "..." with code


class PriceChecker():

# Constructor

def __init__(self):

self.levelsList = []

# Properties

@property

def levelsList(self):

return self.__levelsList

@levelsList.setter

def levelsList(self, newValue):

self.__levelsList = newValue

# Class Methods

# =============

# Method: Sort and Display the levelsList

def displayList(self):

print(chr(27) + "[2J") # Clear the screen

print("Price Levels In The List")

print("========================")

# Sort the list in reverse order

...

# Print the items in the list (Based on the above sort, numbers should appear from large to small.)

...


Instructions: Replace the ellipsis "..." with code


Write an if-else statement that compares the age variable with the value 65. If age is greater than or equal to 65, add 1 to senior_citizens. Otherwise, add 1 to non_seniors.


Given a student has scored

M marks in Maths, P marks in Physics and C marks in Chemistry. Write a program to check if a student is eligible for admission in a professional course based on the following criteria:Sum of marks in any two subjects >= 100 and M + P + C >= 180.


You are the given temperature conversion Tof an object in one of celsius,Fahrenheit and Kelvin scales
LATEST TUTORIALS
APPROVED BY CLIENTS