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

A teacher asked Ramesh to draw a Quadrilateral of a specific pattern with only symbol. The length and height should be L. Here L is the number of characters in every line.The height of the * quadrilateral is the number of lines it contains.
The slope of the quadrilateral taken as S represents the the number of extra space characters in a line when compared to its next line.
The last line will not have any space characters before the character.

Sample Input
6
9
Sample Output1
         ******
       ******
     ******
   ******
 ******
******


list contains numbers. Write a program for containing only prime numbers.


 Write a python function Read_Prime(fname, list) which takes a list of numbers as an input, use this number to write them in a file "primes.txt" . The function then read the file and return a list containing only prime numbers as shown in the example. Also, write the exception handling code to show the proper message.

 

Example-1

Example-2

Example-2

Input:

primes.txt

[1,2,3,4,5,6,7]

 

Output:

[1,2,3,5,7]

Input:

primes.txt

[3,6,5,13,18,21]

 

Output:

[3,5,13]

Input:

primes.txt

[2,4,6,8,10]

 

Output:

[2]

 

mean,median and mode

given a list of integers,write a program to print the mean,median and mode

mean - the average value of all the numbers.

median - the mid point value in the sorted list.

mode - the most common value in the list. if multiple elements with same frequency are present, print all values with same frequency in increasing order.

input

the input will be a single line of containing space-separated integers.

output

the first line of output should contain the mean, round off the value to 2 decimal places.

the second line of output should contain the median, round off the value to 2 decimal places

the third line of output should contain the mode

mean should always be a float value

mean should be a float value when there are even number of elements, otherwise should be an integer value

see sample input/output for the output format

explanation

for example, if the given list of integers are

2 4 5 6 7 8 2 4 5 2 3 8

the average of all the numbers is 4.67.

after sorting the array,

2 2 2 3 4 4 5 6 7 8 8



shift numbers -2


given a string, write a program to move all the numbers in it to its start.


input


the input will contain a string A.


output


the output should contain a string after moving all the numbers in it to its start.


explanation


for example, if the given string A is "1good23morning456",the output should be "123456goodmorning",as it contains numbers at the start.


sample input 1


1good23morning456


sample output 2


123456goodmorning


sample input 2


com876binat25ion


sample output 2


87625combination


sum prime numbers in the input



given a list of integers, write a program to print the sum of all prime numbers in the list of prime numbers.


note.one is either prime nor composite number.



input



the input will be a single line containing space separated integers..



output



the output should be a single line containing the sum of all prime numbers from 1 to N



explanation



for example, if the given list of integers are



2 4 5 6 7 3 8



as 2,3,5 and 7 are prime numbers,your code should print the sum of these numbers. so the output should be 17



sample input 1



2 4 5 6 7 3 8



sample output 1



17



sample input 2



65 87 96 31 32 86 57 69 20 42



sample output 2



31



sum of prime numbers from M to N


Given two integers M and N, write a program to print the sum of prime numbers from M to N.(Both M and N are inclusive.)


input


the first line of input will contain a positive integer(M)

The second line of input will contain a positive integer (N)


output


the output should be a single line containing the sum of prime numbers from M to N


Explanation


for example, if the given M and N are 5 and 11 as all the prime numbers from 5 to 11 are 5, 7 and 11 . so the output should be sum of these primes(5+7+11), which is 23


similarly, if the given numbers are M is 18 and 40, as all the prime numbers from 18 to 40 are 19,23,23,31 and 37. so the output should be sum of these primes (19+23+29+31+37), which is 139.


sample input 1

5

11


sample output 1

23


sample input 2

18

40


sample output 1

139



index of last occurrence


write s program to print the index of the last occurence of the given number N in the list.


input


the first line of input will contain space separated integers.

the second line of input will contain an integer N


output


the output should be the index of the last occurence of the number N


explanation


for example, if the given list of numbers and N are


2 4 5 6 7 8 2 4 5 2 3 8 2


number 2 present at index locations 0, 6, 9, as the last occurence, is at index 9. so the output should be 9.


sample input 1

2 4 5 6 7 8 2 4 5 2 3 8 2


sample output 1

9


sample input 2

65 87 96 31 32 86 57 69 20 42 32 32 32


sample output 2

11


first letters



you are given three strings are inputs. write a program to print the first character of each string.



input



the first,second and third lines of input are strings.



explanation



consider the given strings to be apple, banana and carrot.we need to consider the first character in each of these strings we get the character a from the string apple. we get the character b from the string banana. we get the character c from the string carrot. so the final output should be abc



sample input 1



apple


banana


carrot



sample output 1


abc



sample input 1



very


important


person



sample output 2


vip



compare last three characters


write a program to check if the three last characters in the given two 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 strings, the last three characters ple are commom


so the output should be true.


sample input 1

apple

pimple


sample output 1

true


sample input 2

meals

deal


sample output 2

faslse


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS