Write a program that tests if a number is prime or not. Input a number from the user. The output should be ‘True’ if the number is a prime, ‘False’ otherwise.
Write a program to print the first n Fibonacci numbers. Write separate iterative and recursive versions. Which version do you suspect is more efficient ? Why ?
Write a program that takes a positive integer as input and prints its factorial. Write two separate functions, one that computes the factorial iteratively, and the other recursively.
String &Regular Expressions
Write a python script to take two string S1 and S2 and do the following:
Check S1 and S2 are anagrams or not.
Check S1 is Sub string of S2 or not.
S1 is palindrome or not
Imagine a collection of nuts and bolts that are all together in one pile on a table. Describe, in pseudocode, how you would find all matching pairs of nuts and bolts. You need to find one solution for each of the problem-solving approaches given below. For each of your solution, determine how many comparisons of pairs of nuts and bolts you might have to make in the best- and worst- case scenario. You can assume that there are complete pairs, no single nuts or bolts, and that for each bolt, there is exactly one nut that fits. Describe a solution to the nuts and bolts problem (in pseudocode) using a Divide and Conquer Approach.
Imagine a collection of nuts and bolts that are all together in one pile on a table. Describe, in pseudocode, how you would find all matching pairs of nuts and bolts. You need to find one solution for each of the problem-solving approaches given below. For each of your solution, determine how many comparisons of pairs of nuts and bolts you might have to make in the best- and worst- case scenario. You can assume that there are complete pairs, no single nuts or bolts, and that for each bolt, there is exactly one nut that fits. Describe a solution to the nuts and bolts problem (in pseudocode) using a Brute Force Approach.
a) Write a program using functions to imitate a university canteen ticketing system. A student is required to enter their registration number and pin to access the food menu and make payments. Also a student is allowed to enter only two times a wrong pin before account is blocked.
b) Demonstrate using functions to calculate the area and perimeter as right angled triangle. Given that the perimeter of a triangle is the sum of all three sides and the hypotenuse of a triangle is obtained by sqtr((len * len)+(height * height)) where sqtr() is in a built-in function.
For a in range (2,5): print (a+(a-1)
there are multiple (T) bookstores in the area. Each shopkeeper has a list of B integers that represent the cost of each book.You have different pocket money P for each bookstore. Write a program to calculate the maximum number of books you can buy in each bookstore with the corresponding pocket money
Aleena’s sister who studies in UK coming to Pakistan over winter break. She wants to make a
program that easily calculates the difference between the time of arrival and departure of her
flight.
Write a program that takes in an input from the user for the time of arrival and time of departure
in military format. Using an if/else statement, find the difference in number of hours and minutes
between the two times. Keep in mind that the time of departure is later than the time of arrival
otherwise the program should give an error, “Incorrect Input”.