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

First Prime Number

You are given N inputs. Write a program to print the first prime number in the given inputs.

Input

The first line of input is an integer N. The next N lines each contain an integer. Explanation

In the given example of

5 integers

1

10

4

3

2


The output should be

3.

Sample Input 1

5

1

10

4

3

2

Sample Output 1

3

Sample Input 2

4

2

3

5

7

Sample Output 2

2


Average of Given Numbers


You are given space-separated integers as input. Write a program to print the average of the given numbers.


Input


The first line of input contains space-separated integers.


Output


The output should be a float value rounded up to two decimal places.


Explanation


In the example, input is


1, 0, 2, 5, 9, 8. The sum of all numbers present in the list is 25, and their average is 25/6.


So, the output should be


4.17.


Sample Input 1

1 0 2 5 9 8

Sample Output 1

4.17

Sample Input 2

1 2 3 4 5

Sample Output 2

3.0


Reverse the sentence


your are given a string S as input , write a program to print the string after reversing words of the given sentence.


the first line of input is S.


in the given example the sentence "This is Python" contain 3 words ,when reversing the word "Python" comes to the starting of the sentence and "This" goes to the last of the sentence ,the word "is" remains in the same position.


so the output should be Python is This.



SAMPLE INPUT 1

This is Python

OUTPUT :- Python is This

SAMPLE INPUT 2

Hi! World Hello

OUTPUT:- Hello World Hi!



You are given a square matrix A of dimensions NxN and an integer X which means is an element of A, write a program to find P by performing the following table


(Use Big O to calculate the following time complexity)

Q 1  

def printPairs(array):

    for i in array:

        for j in array:

            print(str(i)+","+str(j))



Q2

def printUnorderedPairs(array):

    for i in range(0,len(array)):

        for j in range(i+1,len(array)):

            print(array[i] + "," + array[j])



#Question3

def printUnorderedPairs(arrayA, arrayB):

    for i in range(len(arrayA)):

        for j in range(len(arrayB)):

            if arrayA[i] < arrayB[j]:

                print(str(arrayA[i]) + "," + str(arrayB[j]))


arrayA = [1,2,3,4,5]

arrayB = [2,6,7,8]


construct a python program to A taxi driver charges the bill as follows. On a fine day, Mr. Roy travels to his office by the taxi. Write a Python program to accept the kilometers traveled by Mr. Roy and calculate his taxi bill. 


Find the sum of the first 10 numbers that are divisible by 3 and 9.

Sample Output

495


1)   Write a Python program that prints all the numbers from 11 to 20 except 13 and 17 using For loop.



https://we.tl/t-AYbqXOvbk2


How to develop model in python?

LATEST TUTORIALS
APPROVED BY CLIENTS