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

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.


Write a program that keeps a person’s name and his/her contact number in a dictionary as key- value pairs. The program should display a menu that lets the user:

a. see a list of all contacts and their numbers,

b. add a new contact and number,

c. change the number of an existing contact, and

d. delete an existing contact and number.

The program should save the dictionary when the user exits the program. Each time the program starts, it should retrieve the dictionary from the file.

For more information on file reading & writing in Python, please have a look at these websites:

https://www.geeksforgeeks.org/how-to-read-from-a-file-in-python/?ref=lbp https://www.geeksforgeeks.org/writing-to-file-in-python/?ref=lbp


1. You have to write a program to check Pak-Studies exam. The exam has 40 MCQS. You have to store correct answers in a list.

1. A 2. C 3. A 4. A 5. D 6. B 7. C 8. A 9. C 10. B

11. A 12. D 13. C 14. A 15. D 16. C 17. B 18. B 19. D 20. A

21. A 22. C

23. A 24. A 25. D

26. B 27. C 28. A

29. C 30. B

31. A 32. D 33. C

34. A 35. D 36. C

37. B 38. B 39. D

40. A

Create another list and store student answers in it. Your program should check for correct answers. A student needs to answer 30 correct answers out of 40 to pass the exam. Your program must show whether the student has passed or failed the exam, the total number of correct answers, the total number of incorrect answers and a list of incorrect questions.



Write a program to input side of a square and find the area and perimeter of a square.