-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonbyexamples.txt
More file actions
127 lines (115 loc) · 8.11 KB
/
pythonbyexamples.txt
File metadata and controls
127 lines (115 loc) · 8.11 KB
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
1. Install Python in your machine and query the version of the Python installed
2. Print the strings - "Hello, World", "Python is a wonderful language", "I am beginner in Python"
3. Assign the strings in the previous exercise to a variable and use the variable to print the string
4. Get the name of the user as input and greet the user saying "Hi <firstname>"
5. Get the name of the user as inputs and greet the user saying "Good Morning, <firstname>" or
"Good Afternoon, <firstname>" depending upon the time of the day
6. Given the radius of the circle, write a program to print the circumference and area of the circle.
Write functions to calculate area and circumference
7. Given the area of the circle, write a program to print the radius
8. Given a number, find whether or not it is prime
9. Given a number, find the next prime number (if 8 is the input, the function should return 11. If 11 is input, it
should return 13)
10. Given a number, find the prime number that comes first when we count backwards. (if 11 is input, it should
return 7. If 9 is inputs, it should return 7)
11. Print the command line arguments of the program with each arguments printed in a line
12. Write a program to whether or not the given string is a valid email address
13. Given few words, convert them to lowercase, UPPERCASE and CamelCase. Print them to the console
14. Given a string, find the length of the string and print it to the console
15. You are running a tea shop, write a program to sell the beverages such as "tea", "coffee", "milk" etc. Print
the menu card to the user and also total sales of the day for each item and overall sales
16. A list has numbers. Write a program to move odd number to start of the list and even number to the end of the list.
list = [1,2,3,4,5,6,7,8,9,10] should be transformed to [1,3,5,7,9,2,4,6,8,10]
17. For a list that has numbers, find sum of odd numbers and sum of even numbers
18. Write a program to find the largest number in the list.
19. Given a number "N" and a list that has numbers, write a program to find the Nth largest element in the list
20. Write a program to find the factorial of given number
21. Given the value of m and n, write a program find permutation and combination
22. Given a date, write a program to find the number of days between the given date and today
23. Implement an address book (or contact book) with add, edit and delete functionality. Store the address book as
contacts.json in your harddisk
24. Given the amount, write a program to find out the minimum number of coins/notes required to total up to the amount.
denominations = [2000, 500, 200, 100, 50, 20, 10, 5, 2, 1]
For 2000, it should return 1
For 2001, it should return 2
For 510, it should return 2
For 512, it should return 3
25. Write to program to read a text file and return number of sentences, words and characters in the file
26. Write a program to read a webpage (ex: http://www.google.com)
27. Write TimeServer that uses HTTP (instead of TCP, it should use HTTP)
28. Implement a tiny RESTful Server using Flask that accepts only GET requests. Implement TimeServer as RESTful Service
29. Write a python function that returns first "N" fibonacci numbers for given "N"
30. Write a program to find whether the given string is a palindrome or not
31. Write a program that returns GCD of two numbers
32. Write a program that returns LCM of two numbers
33. Create a calculator covering all operations (Including basic arith, scientific, Odd/Even/Factorial, Primality,
etc) - This puts many in one
34. Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
between 2000 and 3200 (both included)
35. With a given integral number n, write a program to generate a dictionary that contains (i, i*i) such that is an
integral number between 1 and n (both included) and then the program should print the dictionary.
Suppose the following input is supplied to the program
36. Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in
the i-th row and j-th column of the array should be i*j.Note: i=0,1.., X-1; j=0,1,¡¬Y-1.Example Suppose the
following inputs are given to the program: 3,5Then, the output of the program should be: [[0, 0, 0, 0, 0],
[0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]
37. Write a program that accepts a sequence of whitespace separated words as input and prints the words after
removing all duplicate words and sorting them alphanumerically.
38. NumPy operations to sequence arrays and multiplying lists
39. Implement a function that takes as input three variables, and returns the largest of the three.
Do this without using the Python max() function!
40. Write a program that computes the net amount of a bank account based a transaction log from console input.
The transaction log format is shown as following:D 100W 200
D means deposit while W means withdrawal.Suppose the following input is supplied to the program:
D 300 D 300 W 200 D 100 Then, the output should be:500
41. You are required to write a program to sort the (name, age, height) tuples by ascending order where name is string,
age and height are numbers. The tuples are input by console. The sort criteria is: 1: Sort based on name; 2:
Then sort based on age; 3: Then sort by score.
42. Ask the user for a string and print out whether this string is a palindrome or not.
43. Write a program that takes a list of numbers and makes a new list of only the first and last elements of the
given list, using a function
44. Write a program (function!) that takes a list and returns a new list that contains all the elements of the
first list minus all the duplicates - using Sets
45. Write a password generator in Python - For Randomness and creativity
46. Write a program (using functions!) that asks the user for a long string containing multiple words. Print back
to the user the same string, except with the words in backwards order (Reverse words in Strings)
47. Write a function that takes an ordered list of numbers (a list where the elements are in order from smallest
to largest) and another number. The function decides whether or not the given number is inside the list and
returns (then prints) an appropriate boolean.
48. Create Birthday Dictionary and print the date based on the name
49. Tic tac Toe and Hangman problems
[SENTHIL]
Primarily focussing on interview
Basic Python Interview Questions
1. What is the difference between list and tuples?
2. How is memory managed in Python?
3. Explain Inheritance in Python with an example.
4. Whenever Python exits, why isn’t all the memory de-allocated?
5. What is dictionary in Python?
6. What is the process of compilation and linking in python?
7. Explain split(), sub(), subn() methods of “re” module in Python.
8. What is the difference between range & xrange?
9. What is pickling and unpickling?
10. Explain the use of try: except raise, and finally, Illustrate the proper use of Python error handling.
11. How to retrieve data from a table in MySQL database through Python code? Explain.
Python for DataScience
12. What is map function in Python?
13. How to get indices of N maximum values in a NumPy array?
14. How do you calculate percentiles with Python/ NumPy?
15. What advantages do NumPy arrays offer over (nested) Python lists?
16. Explain the use of decorators.
17. What is the difference between NumPy and SciPy?
18. How do you make 3D plots/visualizations using NumPy/SciPy?
19. Reading Files with Open
20. Writing files with Open
21. Pandas
22. One Dimensional Numpy
23. Two Dimensional Numpy
https://www.edureka.co/blog/interview-questions/python-interview-questions/
https://www.techbeamers.com/python-interview-questions-programmers/
https://intellipaat.com/interview-question/python-interview-questions/
https://mindmajix.com/python-interview-questions
https://stackoverflow.com/questions/8011797/open-read-and-close-a-file-in-1-line-of-code
https://www.pythonforbeginners.com/files/reading-and-writing-files-in-python
https://medium.com/@kacawi/tutorial-pandas-data-structures-736ded97842
https://jakevdp.github.io/PythonDataScienceHandbook/02.02-the-basics-of-numpy-arrays.html