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

3-digit Armstrong Number

Write a program to check if a given 3-digit number

X is an Armstrong number or not.Note: A number is an Armstrong number if the number is equal to the sum of the Nth power of its digits.Input

The first line is an integer

X.Output

The output should be a single line containing

True if it satisfies the given conditions, False in all other cases.Explanation

In the given example

X = 371, The number of digits in 371 is 3. So, 33 + 73 + 13 = 371. Hence,

371 is an Armstrong number.So, the output should be

True


Uncommon Number

Given a number

N, find whether the number is common or uncommon. A number is considered uncommon if it is not divisible by any of the single-digit primes.Input

The first line of input is an integer

N.Output

The output should be a single line containing

True if it satisfies the given conditions, False in all other cases.Explanation

In the given example,

N = 5633 the number is not divisible by 2, 3, 5, 7. So, the number is an uncommon number.Therefore, the output should be

True.


Eligibility Criteria - 4

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. If any one of the below conditions is satisfied then the student is eligible.1) M >= 60, P >= 50, C >= 45 and M + P + C >= 180.

2) Total in M and P >= 120 or Total in C and P >= 110.

Input

The first line is an integer

M The second line is an integer P The third line is an integer COutput

The output should be a single line containing

True if it satisfies the given conditions, False in all other cases.Explanation

Given

M = 72, P = 65, C = 51, the scores of this student satisfies the first condition


M >= 60, (72 >= 60)

P >= 50 (65 >= 50)

C >= 45 (51 >= 45)

M + P + C >= 180 (72 + 65 + 51 >= 180)

 


So, the student is eligible.


Eligibility Criteria - 3

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:


M >= 35, P >= 35, C >= 35 and total in any of the two subjects >= 90.


Input

The first line is an integer M, the second line is an integer P and the third line is an integer C.


Output

The output should be a single line containing True if it satisfies the given conditions, False in all other cases.


Explanation

Given M = 50, P = 35, C = 40


So, the output should be True


 # Method: Write levelsList to levelsFile (override the existing file)

    def writeLevelsToFile(self):

 # Open the file in a way that will override the existing file (if it already exists)

  # Use a loop to iterate over levelsList item by item

 # Convert everything in the item to a string and then add \n to it - before writing it to the file

# Close the file

# Method: Load levelsList using the data in levelsFile 

def readLevelsFromFile(self):

try:

 # Set levelsList to an empty list 

 # Open the file

 # Use a loop to read through the file line by line

  # If the last two characters in the line is "\n", remove them

# Append the line to levelsList

 # Close the file

 except:

return

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 the correct output.

Masking - 2

Write a program that reads a single line of input and prints the first two and last two characters of the given input and prints the asterisk character (*) in place of the remaining characters.

Explanation

For example, if the given string is

message, then the first two and last two characters are me, ge. Now replacing all the remaining characters with * will give the output me***ge.


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 given correct output and . also should me included.

Compare Last Three Characters

Write a program to check if the last three characters in the two given strings are the same.

Input

The first and second lines of inputs are strings.

Output

The output should be either

True or False.Explanation

Given strings are

apple, pimple. In both the strings, the last three characters ple are common. So the output should be

True


LATEST TUTORIALS
APPROVED BY CLIENTS