This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Questions.txt
172 lines (107 loc) · 8.53 KB
/
Questions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Ocean Part 1
1. Write a program that prints “Namasthey India” to the screen (1 point).
2. Take as input a number n
and print the square, cube and 2n
of the number (1 point).
3. Print the following using four print statements:
*
**
***
****
(1 point) .
4. Write an interactive python program which does the following:
What's your name? John
How old are you? 25
What's your favorite color? Blue
What's your favorite hobby? Reading
(1 point).
5. Understand how to use a if conditional in python. Ask the user to enter a number and check if the number is even or odd (1 point).
6. Write a program to take as input a number n
and display the first n
natural numbers (1 point).
7. Print a sequence of numbers starting from the number a with common difference d. Go on till you reach the number b.
Enter a value for a: 10
Enter a value for d: 3
Enter a value for b: 20
Output: 10 13 16 19
(1 point).
8. Write a program that calculates and prints the sum of all numbers from 1 to n, where n is provided by the user (1 point).
9. Write a program that takes a number n from the user and prints the multiplication table for that number from 1 to 10. Generalize it from i
to j
.
2X1=2
2X2=4
and so on...
(1 point).
10. Write a program to find out if the given number is prime or not (1 point).
Ocean Part 2
11. Write a program to take as input n
and print all prime numbers upto and including n
(1 point).
12. Input two different strings and concatenate it (1 point).
13. Take two strings of the same length and intersperse the second one into the first one:
Input:
india
super
Output:
isnudpiear
(1 point).
14. Given a string, write a program to reverse it (1 point).
15. Given a string, check if it is a palindrome or not (1 point).
16. Write a program that counts and prints the number of vowels and the number of consonants in the string (1 point).
17. List of Squares: Write a program that prints the square of numbers from 1 to n, where n is provided by the user (1 point).
18. Fibonacci Sequence : Write a program that prints the first n numbers in Fibonacci numbers (1 point).
19. Print Star Pattern: Write a program that takes a number n from the user and prints a right-angled triangle pattern with stars of n rows (1 point) .
20. Write a piece of code which does exactly as specified in this video{https://www.youtube.com/watch?v=JA_70M-ma-k} (10 points).
21. Factorial: Write a program that calculates the factorial of a number provided by the user (1 point).
22. Positive or Negative: Write a program that asks the user for a number and prints whether the number is positive, negative, or zero (1 point).
23. Simple Interest Calculation: Write a program that calculates the simple interest for given principal, rate, and time provided by the user (1 point).
24. Temperature Converter: Write a program that converts Celsius to Fahrenheit or Fahrenheit to Celsius, depending on user input (1 point).
25. Leap Year or Not: Write a program that checks if a given year is a leap year or not. Google for the details on how to figure out if the given number is a leap year or not. It is more complicated than simply checking for a multiple of 4 (1 point).
26. Divisible by 7 and 5: Write a program that checks if a number provided by the user is divisible by both 7 and 5. Generalize it to a and b (1 point).
27. Create a Python program that prompts the user for their age. If the age is less than 18, print “You are a minor.” If the age is between 18 and 65, print “You are an adult.” Otherwise, print “You are a senior citizen.” (1 point).
28. Grading System: Write a program that takes the marks of five subjects from the user and calculates the grade according to the average marks: A if average >= 90 B if average >= 80 and < 90 C if average >= 70 and < 80 D if average >= 60 and < 70 F otherwise (1 point).
29. Decimal to Binary Conversion: Write a program that converts a decimal number to its binary representation using loops, without using built-in conversion functions (1 point).
30. Write a program that finds the gcd of two numbers using Euclid’s Algrorithm. Given k
as an input, display those two numbers, both with k
digits, such that they take the maximum number of steps to find the GCD, across all the pair of numbers, both of which are of k
digits (8 points).
31. Write a program to populate a list L
with the first n
natural numbers (1 point).
32. Write a program to populate a list L
with random numbers in the range 1 to 1000 (1 point).
Ocean Part 3
(Watch these videos, as and when required)
33. Write a function called add that takes two numbers as arguments and returns their sum. (1 point)
34. Write a function called factorial that takes an integer n and returns the factorial of n. (1 point)
35. Write a function called fibonacci that takes an integer n and returns the n-th number in the Fibonacci sequence. (1 point)
36. Write a function which simulates the process of throwing n
identical balls into n
bins. What is the maximum across the buckets? Write a short report on the output of your code. (2 points)
37. Write a function which simulates the process of throwing identical balls into n
identical bins until all the bins are non-empty. How many balls are we expected to throw? Investigate and write a short report based on your observation. (2 points)
38. Checking for Even or Odd: Write a function called is_even that takes an integer and returns True if the number is even, and False if it is odd. (1 point)
39. Calculate Area of a Circle: Write a function called circle_area that takes the radius of a circle as an argument and returns its area. (1 point)
40. Write a function that displays the spiral: RULLDDRRRUUULLLL… and so on. It should keep displaying until it has displayed 1,000,000 Letters in this pattern. (5 points)
41. Concatenating Strings: Write a function called concatenate that takes two strings and returns them concatenated together with a space between them. (1 point)
42. Finding the Maximum: Write a function called find_max that takes a list of numbers and returns the largest number in the list. (1 point)
43. Consider the sensex data from here{https://www.kaggle.com/code/kerneler/starter-bse-sensex-index-30-yrs-111d3b62-d/input}. Consider only the end of the day closing values. When should you have bought and when should you have sold in order to gain the maximum return in this 30 year period? You can assume that you can buy the stocks partially and you start with, let us say 1,00,000 Rupees. (10 points)
44. Consider the data of Height and Weight of 25,000 people as available here{https://www.kaggle.com/datasets/burnoutminer/heights-and-weights-dataset}. Is the data correlated? What is the correlation? Can you plot the points and fit a line? You are free to use any built in functions, but you should know what the functions are doing. Correlation is a statistical concept which you may know from your high school, we only expect you to understand this concept at an intuitive level. (5 point)
Ocean Part 4
45. Reading exercise (first few chapters of Algorithms to live by). (25 points)
46. Write a function that takes as inputs list of lists that depicts square matrices A and B and then gives us the sum. (1 point)
47. Write a function that takes as inputs list of lists that depicts square matrices A and B and then gives us the product. (2 points)
48. Write a function that writes the first n numbers and writes it to a file by name output.txt (1 point)
49. Write a function that reads a file which has numbers in each line and outputs it on the screen one by one. (1 point)
50. Solve this question.{image in git repo named sfc.png} (10 points)
51. Write a program to sort a list of numbers using the bubble sort technique. (1 point)
52. Write a program to sort a list of numbers using the merge sort technique. (2 point)
53. Write a program to sort a list of numbers using the quick sort technique. (2 point)
54. Write a program to search for an element in a list using Binary Search.(2 point)
55. Write a program which, given a text file comprising of all words in lower case, one word per line, sorts this file using bubble sort, merge sort and quick sort. Which technique is the fastest and why? Write a detailed report. (5 points)
56. Write a program to find the median element in a list of unsorted elements. You are not supposed to sort the list. (2 points)
57. Solve the contiguous sum sub array problem (1 point).
58. We solved the SFC question a while ago. Can you solve this{https://en.wikipedia.org/wiki/Peano_curve} on similar lines? (2 points)
59. Write a program to encrypt a string using caesar cipher. (1 point)
60. Read and Solve this (20 points)