Skip to content

Commit 6a3ef77

Browse files
committed
create questions
1 parent 02f8533 commit 6a3ef77

File tree

100 files changed

+1803
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1803
-0
lines changed

my_exercises/question_1.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 1
7+
# Level 1
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
13+
# between 2000 and 3200 (both included).
14+
# The numbers obtained should be printed in a comma-separated sequence on a single line.
15+
#
16+
# Hints:
17+
# Consider use range(#begin, #end) method
18+
#
19+
################################################################

my_exercises/question_10.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 10
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# 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.
13+
# Suppose the following input is supplied to the program:
14+
# hello world and practice makes perfect and hello world again
15+
# Then, the output should be:
16+
# again and hello makes perfect practice world
17+
#
18+
# Hints:
19+
# In case of input data being supplied to the question, it should be assumed to be a console input.
20+
# We use set container to remove duplicated data automatically and then use sorted() to sort the data.
21+
#
22+
################################################################

my_exercises/question_100.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
#
7+
################################################################
8+
#
9+
# Question:
10+
# Write a program to solve a classic ancient Chinese puzzle:
11+
# We count 35 heads and 94 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have?
12+
# Hint:
13+
# Use for loop to iterate all possible solutions.
14+
#
15+
#
16+
################################################################

my_exercises/question_11.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 11
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# 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.
13+
# Example:
14+
# 0100,0011,1010,1001
15+
# Then the output should be:
16+
# 1010
17+
# Notes: Assume the data is input by console.
18+
#
19+
# Hints:
20+
# In case of input data being supplied to the question, it should be assumed to be a console input.
21+
#
22+
################################################################

my_exercises/question_12.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 12
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
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.
13+
# The numbers obtained should be printed in a comma-separated sequence on a single line.
14+
#
15+
# Hints:
16+
# In case of input data being supplied to the question, it should be assumed to be a console input.
17+
#
18+
################################################################

my_exercises/question_13.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 13
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# Write a program that accepts a sentence and calculate the number of letters and digits.
13+
# Suppose the following input is supplied to the program:
14+
# hello world! 123
15+
# Then, the output should be:
16+
# LETTERS 10
17+
# DIGITS 3
18+
#
19+
# Hints:
20+
# In case of input data being supplied to the question, it should be assumed to be a console input.
21+
#
22+
################################################################

my_exercises/question_14.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 14
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters.
13+
# Suppose the following input is supplied to the program:
14+
# Hello world!
15+
# Then, the output should be:
16+
# UPPER CASE 1
17+
# LOWER CASE 9
18+
#
19+
# Hints:
20+
# In case of input data being supplied to the question, it should be assumed to be a console input.
21+
#
22+
################################################################

my_exercises/question_15.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 15
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a.
13+
# Suppose the following input is supplied to the program:
14+
# 9
15+
# Then, the output should be:
16+
# 11106
17+
#
18+
# Hints:
19+
# In case of input data being supplied to the question, it should be assumed to be a console input.
20+
#
21+
################################################################

my_exercises/question_16.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 16
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# Use a list comprehension to square each odd number in a list. The list is input by a sequence of comma-separated numbers.
13+
# Suppose the following input is supplied to the program:
14+
# 1,2,3,4,5,6,7,8,9
15+
# Then, the output should be:
16+
# 1,3,5,7,9
17+
#
18+
# Hints:
19+
# In case of input data being supplied to the question, it should be assumed to be a console input.
20+
#
21+
################################################################

my_exercises/question_17.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
################################################################
5+
#
6+
# Question 17
7+
# Level 2
8+
#
9+
################################################################
10+
#
11+
# Question:
12+
# 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:
13+
# D 100
14+
# W 200
15+
# D means deposit while W means withdrawal.
16+
# Suppose the following input is supplied to the program:
17+
# D 300
18+
# D 300
19+
# W 200
20+
# D 100
21+
# Then, the output should be:
22+
# 500
23+
#
24+
# Hints:
25+
# In case of input data being supplied to the question, it should be assumed to be a console input.
26+
#
27+
################################################################

0 commit comments

Comments
 (0)