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 program to find the sum S of the series where S = x-x^3+x^5+..... upto N terms.


Inputs
5
5
Output
Equal
If the given number are equal print "Equal". In all other cases, print "not equal"

given an integer number N as input. write a program to print the right-angled triangular pattern of N rows as shown below.


you are given two given numbers, A and B where 1<= A <=B, write a program to find the number of perfect squares in range A to B (including A and B).


6. Create an array with whole numbers values from 0 to 10 and find what is the command to extract the elements in the following sequence -


array ([7,4,1])




7. Create a NumPy array having user input values and convert the integer type to the float type of the elements of the array. For instance:


Original array [1, 2, 3, 4]


Array converted to a float type: [ 1. 2. 3. 4.]






8. Write a NumPy program to append values to the end of an array. For instance:


Original array: [10, 20, 30]


After append values to the end of the array:


[10 20 30 40 50 60 70 80 90]


9. Create a 2 dimensional array with 3 rows and 3 columns containing random numbers from 1 to 9. Find the difference between the maximum element across the columns and the minimum element across the rows.






10. Create a 3*3 array having values from 10-90(interval of 10) and store that in array1. Perform the following tasks:


a. Extract the 1st row from the array.


b. Extract the last element from the array.




1. Create a list named ‘myList’ that has the following elements: 10,20,30,’apple’, True, 8.10.

a. Now in the ‘myList’, append these values: 30,40

b. After that reverse the elements of the ‘myList’ and store that in ‘reversedList’

 

 

2. Create a dictionary ‘Country’ that maps the following countries to their capitals respectively:

 

Country

India

China

Japan

Qatar

France

State

Delhi

Beijing

Tokyo

Doha

Marseilles

 

Find 2 commands to replace “Marseilles” with “Paris”.

 

3. Create the tuples given below

tuple_1 = (1,5,6,7,8)

tuple_2 = (8,9,4)

Identify which of the following code does not work on a tuple.

 

a) sum(tuple_1)

b) len(tuple_2)

c) tuple_2 + tuple_1

d) tuple_1[3] = 45

 



Add two polynomialsGiven two polynomials A and B, write a program that adds the giventwo polynomials A and B

5

0 -2

3 6

4 7

1 -3

2 -1

5

0 1

1 2

2 -4

3 3

4 5


output : 12x^4 + 9x^3 - 5x^2 - x - 1





Write a program to sort a list of integers using Insertion sort, Mergesort and Quicksort. First take as input the size ‘n’ of the array, then read in the ‘n’ input integers that need to be sorted.


Write a program that takes a sentence as input from the user, and prints the frequency of each

 word in the sentence and neglects any punctuations. ‘.’,’,’,’!’ Input: Hello Amna. Amna is a good girl.

Output:

Hello: 1 Amna: 2 is: 1

a: 1 good: 1 girl:1


Write a program to sort a list of integers using Insertion sort, Mergesort and Quicksort. First take as input the size ‘n’ of the array, then read in the ‘n’ input integers that need to be sorted.


LATEST TUTORIALS
APPROVED BY CLIENTS