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

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

Create a program in Python to accept input from a student and then display if the student is eligible to graduate and if so if they will graduate cum laude, magna cum laude or summa cum laude.  

Your program should prompt the student to enter his/her name and gpa. If the gpa is 4.0, then display a message stating that he/she has graduated summa cum laude. If the gpa is less than 4.0 but greater than or equal to 3.8, then display a message that they have graduated magna cum laude. If the gpa is not greater than or equal to 3.8 but greater than or equal to 3.5, then display a message that they have graduated cum laude. If the gpa is less than 3.5 but greater than 2.0, display a message that they have graduated. If the gpa is less than 2.0, display a message that they are not eligible to graduate but can take more courses to bring their gpa up to at least 2.0.


LATEST TUTORIALS
APPROVED BY CLIENTS