6phrase - Myslate - Python - Session Plan
6phrase - Myslate - Python - Session Plan
6phrase - Myslate - Python - Session Plan
Day 1
1. 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).The numbers
obtained should be printed in a comma-separated sequence on a single line.
Day 2
4. Write a program which accepts a sequence of comma-separated numbers from
console and generate a list and a tuple which contains every number.Suppose
the following input is supplied to the program:
34,67,55,33,12,98
Then, the output should be:
['34', '67', '55', '33', '12', '98']
('34', '67', '55', '33', '12', '98')
Also please include simple test function to test the class methods.
6. Write a program that calculates and prints the value according to the given
formula:
Q = Square root of [(2 * C * D)/H]
Six Phrase - mySLATE
9. Write a program that accepts sequence of lines as input and prints the lines
after making all characters in the sentence capitalized.
Suppose the following input is supplied to the program:
Hello world
Practice makes perfect
Then, the output should be:
HELLO WORLD
PRACTICE MAKES PERFECT
Day 3
10. 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.
Suppose the following input is supplied to the program:
Six Phrase - mySLATE
hello world and practice makes perfect and hello world again
Then, the output should be:
11. Write a program which accepts a sequence of comma separated 4 digit binary
numbers as its input and then check whether they are divisible by 5 or not. The
numbers that are divisible by 5 are to be printed in a comma separated
sequence.
Example:
0100,0011,1010,1001
Then the output should be:
1010
12. Write a program, which will find all such numbers between 1000 and 3000
(both included) such that each digit of the number is an even number.The
numbers obtained should be printed in a comma-separated sequence on a
single line.
13. Write a program that accepts a sentence and calculate the number of letters
and digits.
LETTERS 10
DIGITS 3
14. Write a program that computes the value of a+aa+aaa+aaaa with a given digit
as the value of a.
9
Then, the output should be:
11106
Day 4
15. Use a list comprehension to square each odd number in a list. The list is input
by a sequence of comma-separated numbers. Suppose the following input is
supplied to the program:
Six Phrase - mySLATE
1,2,3,4,5,6,7,8,9
Then, the output should be:
1,9,25,49,81
16. 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 100
W 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
19. You are required to write a program to sort the (name, age, score) tuples by
ascending order where name is string, age and score are numbers. The tuples
are input by console. The sort criteria is:
Jony,17,91
Jony,17,93
Json,21,85
Then, the output of the program should be:
[('John', '20', '90'), ('Jony', '17', '91'), ('Jony', '17', '93'), ('Json', '21', '85'), ('Tom',
'19', '80')]
Six Phrase - mySLATE
20. Define a class with a generator which can iterate the numbers, which are
divisible by 7, between a given range 0 and n.
21. A robot moves in a plane starting from the original point (0,0). The robot can
move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot
movement is shown as the following:
UP 5
DOWN 3
LEFT 3
RIGHT 2
The numbers after the direction are steps. Please write a program to compute
the distance from current position after a sequence of movement and original
point. If the distance is a float, then just print the nearest integer. Example: If
the following tuples are given as input to the program:
UP 5
DOWN 3
LEFT 3
RIGHT 2
Then, the output of the program should be:
22. Write a program to compute the frequency of the words from the input. The
output should output after sorting the key alphanumerically.
2:2
3.:1
3?:1
New:1
Python:5
Read:1
and:1
between:1
choosing:1
or:2
to:1
24. Python has many built-in functions, and if you do not know how to use it, you
can read document online or find some books. But Python has a built-in
document function for every built-in functions.
Please write a program to print some Python built-in functions documents, such
as abs(), int(), raw_input()
And add document for your own function
25. Define a class, which have a class parameter and have a same instance
parameter.
26. Define a function that can convert a integer into a string and print it in
console.
27. Define a function that can receive two integer numbers in string form and
compute their sum and then print it in console.
28. Define a function which can compute the sum of two numbers.
29. Define a function that can accept two strings as input and concatenate them
and then print it in console.
30. Define a function that can accept two strings as input and print the string with
maximum length in console. If two strings have the same length, then the
function should print all strings line by line.
31. Longest Common Substring
Day 7
32. Define a function which can print a dictionary where the keys are numbers
between 1 and 20 (both included) and the values are square of keys.
33. Define a function which can generate a dictionary where the keys are numbers
between 1 and 20 (both included) and the values are square of keys. The
function should just print the keys only.
34. Define a function which can generate and print a list where the values are
square of numbers between 1 and 20 (both included).
35. Define a function which can generate a list where the values are square of
numbers between 1 and 20 (both included). Then the function needs to print
the first 5 elements in the list.
36. Define a function which can generate a list where the values are square of
numbers between 1 and 20 (both included). Then the function needs to print
the last 5 elements in the list.
37. Define a function which can generate a list where the values are square of
numbers between 1 and 20 (both included). Then the function needs to print
all values except the first 5 elements in the list.
38. Define a function which can generate and print a tuple where the value are
square of numbers between 1 and 20 (both included).
39. Longest Palindromic Subsequence
Six Phrase - mySLATE
Day 8
40. With a given tuple (1,2,3,4,5,6,7,8,9,10), write a program to print the first
half values in one line and the last half values in one line.
41. Write a program to generate and print another tuple whose values are even
numbers in the given tuple (1,2,3,4,5,6,7,8,9,10).
42. Write a program which accepts a string as input to print "Yes" if the string is
"yes" or "YES" or "Yes", otherwise print "No".
43. Write a program which can map() to make a list whose elements are square of
elements in [1,2,3,4,5,6,7,8,9,10].
44. Write a program which can map() and filter() to make a list whose elements
are square of even number in [1,2,3,4,5,6,7,8,9,10].
45. Write a program which can filter() to make a list whose elements are even
number between 1 and 20 (both included).
46. Longest Increasing Subsequence
47. Kadane’s Algorithm
Day 9
48. Write a program which can map() to make a list whose elements are square of
numbers between 1 and 20 (both included).
49. Define a class named American which has a static method called
printNationality.
50. Define a class named American and its subclass NewYorker.
51. Longest Palindromic Subsequence
52. Find the largest kxk submatrix with all entries 1 in a mxn binary matrix
Day 10
53. Define a class named Circle which can be constructed by a radius. The Circle
class has a method which can compute the area.
54. Define a class named Rectangle which can be constructed by a length and
width. The Rectangle class has a method which can compute the area.
Six Phrase - mySLATE
55. Define a class named Shape and its subclass Square. The Square class has an
init function which takes a length as argument. Both classes have a area
function which can print the area of the shape where Shape's area is 0 by
default.
Day 11
58. Write a function to compute 5/0 and use try/except to catch the exceptions.
59. Define a custom exception class which takes a string message as attribute.
60. Assuming that we have some email addresses in the
"[email protected]" format, please write program to print the user
name of a given email address. Both user names and company names are
composed of letters only.
Example: If the following email address is given as input to the program:
[email protected]
Then, the output of the program should be:
john
In case of input data being supplied to the question, it should be assumed to be
a console input.
Day 12
62. Assuming that we have some email addresses in the
"[email protected]" format, please write program to print the
company name of a given email address. Both user names and company names
are composed of letters only.
Example: If the following email address is given as input to the program:
[email protected]
Then, the output of the program should be:
google
In case of input data being supplied to the question, it should be assumed to be
a console input.
Six Phrase - mySLATE
5
Then, the output of the program should be:
3.55
In case of input data being supplied to the question, it should be assumed to be
a console input.
5
Then, the output of the program should be:
500
In case of input data being supplied to the question, it should be assumed to be
a console input.
f(n)=0 if n=0
f(n)=1 if n=1
f(n)=f(n-1)+f(n-2) if n>1
Six Phrase - mySLATE
Please write a program to compute the value of f(n) with a given n input by
console.
7
Then, the output of the program should be:
13
In case of input data being supplied to the question, it should be assumed to be
a console input.
f(n)=0 if n=0
f(n)=1 if n=1
f(n)=f(n-1)+f(n-2) if n>1
Please write a program to compute the value of f(n) with a given n input by
console.
7
Then, the output of the program should be:
0,1,1,2,3,5,8,13
In case of input data being supplied to the question, it should be assumed to be
a console input.
71. Please write a program using generator to print the even numbers between 0
and n in comma separated form while n is input by console.
10
Then, the output of the program should be:
0,2,4,6,8,10
In case of input data being supplied to the question, it should be assumed to be
a console input.
72. Please write a program using generator to print the numbers which can be
divisible by 5 and 7 between 0 and n in comma separated form while n is input
by console.
100
Six Phrase - mySLATE
0,35,70
In case of input data being supplied to the question, it should be assumed to be
a console input.
Day 13
73. Please write assert statements to verify that every number in the list [2,4,6,8]
is even.
74. Please write a program which accepts basic mathematic expression from
console and print the evaluation result.
35 + 3
Then, the output of the program should be:
38
75. Please write a binary search function which searches an item in a sorted list.
The function should return the index of element to be searched in the list.
76. Please generate a random float where the value is between 10 and 100 using
Python module.
77. Please generate a random float where the value is between 5 and 95 using
Python module.
78. Subset Sum Problem
Day 14
79. Please write a program to output a random even number between 0 and 10
inclusive using random module and list comprehension.
80. Please write a program to output a random number, which is divisible by 5 and
7, between 10 and 150 inclusive using random module and list comprehension.
81. Please write a program to generate a list with 5 random numbers between 100
and 200 inclusive.
82. Please write a program to randomly generate a list with 5 even numbers
between 100 and 200 inclusive.
83. Please write a program to randomly generate a list with 5 numbers, which are
divisible by 5 and 7 , between 1 and 1000 inclusive.
Six Phrase - mySLATE
Day 15
85. Please write a program to randomly print a integer number between 7 and 15
inclusive.
86. Please write a program to compress and decompress the string "hello world!
hello world!hello world!hello world!".
87. Please write a program to print the running time of execution of "1+1" for 100
times.
88. Please write a program to shuffle and print the list [3,6,7,8].
89. Please write a program to generate all sentences where subject is in ["I",
"You"] and verb is in ["Play", "Love"] and the object is in ["Hockey","Football"].
90. Largest Area Histogram Problem
Day 16
91. Please write a program to print the list after removing even numbers in
[5,6,77,45,22,12,24].
92. By using list comprehension, please write a program to print the list after
removing numbers which are divisible by 5 and 7 in [12,24,35,70,88,120,155].
93. By using list comprehension, please write a program to print the list after
removing the 0th, 2nd, 4th,6th numbers in [12,24,35,70,88,120,155].
94. By using list comprehension, please write a program to print the list after
removing the 2nd - 4th numbers in [12,24,35,70,88,120,155].
95. By using list comprehension, please write a program generate a 3*5*8 3D array
whose each element is 0.
96. Knight’s Tour Problem
Day 17
97. By using list comprehension, please write a program to print the list after
removing the 0th,4th,5th numbers in [12,24,35,70,88,120,155].
Six Phrase - mySLATE
98. By using list comprehension, please write a program to print the list after
removing the value 24 in [12,24,35,24,88,120,155].
99. With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], write a
program to make a list whose elements are intersection of the above given
lists.
100. With a given list [12,24,35,24,88,120,155,88,120,155], write a program to
print this list after removing all duplicate values with original order reserved.
101. Define a class Person and its two child classes: Male and Female. All classes
have a method "getGender" which can print "Male" for Male class and "Female"
for Female class.
102. Egg Drop Problem
Day 18
103. Please write a program which count and print the numbers of each character
in a string input by console.
Example: If the following string is given as input to the program:
abcdefgabc
Then, the output of the program should be:
a,2
c,2
b,2
e,1
d,1
g,1
f,1
104. Please write a program which accepts a string from console and print it in
reverse order.
Example: If the following string is given as input to the program:*
105. Please write a program which accepts a string from console and print the
characters that have even indexes.
Example: If the following string is given as input to the program:
H1e2l3l4o5w6o7r8l9d
Then, the output of the program should be:
Six Phrase - mySLATE
Helloworld
Day 19
109. Given the participants' score sheet for your University Sports Day, you are
required to find the runner-up score. You are given scores. Store them in a list
and find the score of the runner-up.
23665
110. You are given a string S and width W. Your task is to wrap the string into a
paragraph of width.
ABCDEFGHIJKLIMNOQRSTUVWXYZ
ABCD
EFGH
IJKL
IMNO
Six Phrase - mySLATE
QRST
UVWX
YZ
111. You are given an integer, N. Your task is to print an alphabet rangoli of size
N. (Rangoli is a form of Indian folk art based on creation of patterns.)
#size 3
----c----
--c-b-c--
c-b-a-b-c
--c-b-c--
----c----
#size 5
--------e--------
------e-d-e------
----e-d-c-d-e----
--e-d-c-b-c-d-e--
e-d-c-b-a-b-c-d-e
--e-d-c-b-c-d-e--
----e-d-c-d-e----
------e-d-e------
--------e--------
Six Phrase - mySLATE
Day 20
112. You are given a date. Your task is to find what the day is on that date.
Input
A single line of input containing the space separated month, day and year,
respectively, in MM DD YYYY format.
08 05 2015
Output
WEDNESDAY
Input
The first line of input contains an integer, M.The second line contains M space-
separated integers.The third line contains an integer, N.The fourth line
contains N space-separated integers.
2459
2 4 11 12
Output
Output the symmetric difference integers in ascending order, one per line.
11
12
Six Phrase - mySLATE
114. You are given words. Some words may repeat. For each word, output its
number of occurrences. The output order should correspond with the input
order of appearance of the word. See the sample input/output for clarification.
bcdef
abcdefg
bcde
bcdef
211
115. You are given a string.Your task is to count the frequency of letters of the
string and print the letters in descending order of frequency.
aabbbccde
Then, the output of the program should be:
b3
a2
c2