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 Python program that reads in exam results from the user. The program should then display the number of students who achieved more than 70% in their exam. Assume that the first value read in specifies the number of exam results that are to be entered.


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.

Sample Input 1
message
Sample Output 1
me***ge
Sample Input 2
12345
Sample Output 2
12*45

M = int(input())
P = int(input())
C = int(input())
list1 = [M,P,C]
list2 = []
for i in list1:
  list1.remove(i)
  for j in list1:
    if i + j >= 100 and M + P + C >= 180:
      list2.append(True)
    else:
      list2.append(False)
if False in list2:
  print(False)
else:
  print(True)

The Above code have three test cases, but they were getting only two test cases as expected output, third test case were not getting expected output.

Question url link :- https://drive.google.com/file/d/1xObf_3zdyEfD8yEtB5V4OqL6HVzEd7h1/view?usp=sharing

The test cases are below

Test Case – 1

Input

82

55

45

Output

True

 

Test Case – 2

Input

71

30

70

Output

False

Test Case – 3

Input

40

90

50

Output

True


Years, Weeks & Days

Given 

N number of days as input, write a program to convert N number of days to years (Y), weeks (W) and days (D).

Note: Take 1 year = 365 days.

Input

The input contains single integer 

N.

Output

Print space-separated integers 

Y, W and D.

Explanation

Given  

N = 1329. The value can be written as

1329 = 3 years + 33 weeks + 3 days

So the output should be 

3 33 3.

Sample Input 1
1329
Sample Output 1
3
33
3
Sample Input 2
0
Sample Output 2
0
0
0
Elements in the Range

You are given three numbers. Check if any of the numbers exist in the range from 10 to 20 (including 10 and 20).

Input

The first, second, and third lines of input are integers.

Output

The output should be either 

True or False.

Explanation

Given 

a = 2, b = 4, c = 16, 16 is in the range between 10 and 20.

So the output should be 

True.

Sample Input 1
2
4
16
Sample Output 1
True
Sample Input 2
2
4
6
Sample Output 2
False

Half String - 2

Write a program that prints the second half of the given input string.
You can assume that the length of the input string will always be an even number.

Input

The first line of input is a string.

Output

The output should be a string.

Explanation

In the given string 

messages, the length of the string is 8. The last 4 characters i.e The second half of the string is ages.

So the output should be 

ages.

Sample Input 1
messages
Sample Output 1
ages
Sample Input 2
time
Sample Output 2
me

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.

Sample Input 1

371

Sample Output 1

True




Hollow Rectangle - 2


This Program name is Hollow Rectangle - 2. Write a Python program to Hollow Rectangle - 2


The below link contains Hollow Rectangle - 2 question, explanation and test cases


https://drive.google.com/file/d/1nWuk5uhqVJKhOJbg9IaBoW8S8FUrNSbX/view?usp=sharing


We need exact output when the code was run

Striped Rectangle


This Program name is Striped Rectangle. Write a Python program to Striped Rectangle


The below link contains Striped Rectangle question, explanation and test cases


https://drive.google.com/file/d/1S7V-_Rle5eyT53qc6RBlwfpo3MzdknUH/view?usp=sharing


We need exact output when the code was run

Composite Number


This Program name is Composite Number. Write a Python program to Composite Number


The below link contains Composite Number question, explanation and test cases


https://drive.google.com/file/d/1XrSRAXys8kKSTYMSm58aED455XD_i4tm/view?usp=sharing


We need exact output when the code was run

LATEST TUTORIALS
APPROVED BY CLIENTS