Skip to content

Commit 23a69e0

Browse files
committed
Merge branch 'remote'
2 parents f1976a2 + b8c2ebe commit 23a69e0

File tree

22 files changed

+289
-0
lines changed

22 files changed

+289
-0
lines changed

Raynxxx/0000/ex00.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
__author__ = 'rayn'
2+
3+
#problem 0000
4+
#Add a unread number on the face icon
5+
6+
from PIL import Image
7+
from PIL import ImageFont
8+
from PIL import ImageDraw
9+
10+
class UnreadTagFace:
11+
def __init__(self):
12+
self.img = None
13+
self.num = None
14+
def open(self, image_path):
15+
self.img = Image.open(image_path)
16+
return True
17+
def draw(self, tag_num = 1):
18+
tag_size = max(self.img.size[0], self.img.size[1]) / 5
19+
tag_str = str(tag_num) if tag_num < 100 else '99+'
20+
font = ImageFont.truetype("Arial.ttf", tag_size)
21+
px = self.img.size[0] - font.getsize(tag_str)[0]
22+
draw_pen = ImageDraw.Draw(self.img)
23+
draw_pen.text((px, 0), tag_str, (255, 0, 0), font)
24+
self.img.save('face' + tag_str + '.jpg')
25+
return True
26+
27+
28+
solver = UnreadTagFace()
29+
solver.open('face.jpg')
30+
solver.draw(4)
31+
32+
33+
34+
35+
36+
37+
38+

Raynxxx/0000/face.jpg

15.3 KB
Loading

Raynxxx/0000/face4.jpg

15 KB
Loading
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
# Date: 22-02-15
4+
# Author: Liang
5+
6+
7+
from PIL import Image, ImageDraw, ImageFont
8+
9+
10+
def add_number(image_path, number):
11+
im = Image.open(image_path)
12+
width, height = im.size
13+
14+
# get a drawing context
15+
avatar_draw = ImageDraw.Draw(im)
16+
# set the font of number to draw
17+
font_size = int(height / 4)
18+
number_font = ImageFont.truetype('microsoft_yahei.TTF', font_size)
19+
20+
# Draw the image with a number(xy, text, color, font)
21+
avatar_draw.text(
22+
(width - font_size, 0), str(number), (255, 0, 0), font=number_font)
23+
24+
im.save('./new_avatar.jpg')
25+
im.show()
26+
27+
28+
add_number('avatar.png', 3)

burun/exercise_0000/avatar.png

39.8 KB
Loading
14.3 MB
Binary file not shown.

burun/exercise_0000/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pillow==2.7.0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
# Date: 23-02-15
4+
# Author: Liang
5+
6+
import random
7+
import string
8+
9+
coupon_number = 200
10+
coupon_size = 12
11+
12+
for i in range(coupon_number):
13+
coupon = ''.join(
14+
random.sample(string.digits + string.ascii_uppercase, coupon_size))
15+
print(coupon)

burun/exercise_0004/count_words.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
# Date: 10-03-15
4+
# Author: Liang
5+
6+
import re
7+
import operator
8+
9+
# Read the file
10+
myfile = open('english_text.txt', 'r')
11+
# Extract words from file excluding punctuation and /n
12+
words = re.findall(r"[\w']+", myfile.read())
13+
14+
# Dictionary contains all the words and frequencies
15+
words_dictionary = {}
16+
17+
# Count frequencies
18+
for word in words:
19+
if word not in words_dictionary:
20+
# Put word in dictionary
21+
words_dictionary[word] = 0
22+
for item in words:
23+
if item == word:
24+
words_dictionary[word] += 1
25+
26+
# Sort the words by frequencies
27+
sort_words_dictionary = sorted(
28+
words_dictionary.items(), key=operator.itemgetter(1), reverse=True)
29+
30+
print(sort_words_dictionary)

burun/exercise_0004/english_text.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ClinicalTrials.gov provides a remarkable resource of information regarding drug development for AD and other disorders. Trends in AD drug development over time can be seen, and the movement of the drugs through the pipeline can be monitored. ClinicalTrials.gov has provided comprehensive information since 2007, when registration of clinical trials was required by the FDA. The analyses demonstrate that the number of clinical trials has been declining since the 2008 through 2009 period. The pharmaceutical industry sponsors most drug development for AD, whereas NIH accounts for a relatively small percentage of drug development. The United States has the largest number of clinical trials of any single country, but more clinical trials are conducted outside of the United States than inside of the United States.
2+
Most trials address symptomatic agents intended to improve cognition, but disease-modifying small molecules and disease-modifying immunotherapies are also represented in the drug-development pipeline. More therapies address amyloid-beta targets than any other single target. Phase 2 trials are smaller and shorter than Phase 3 trials, and sponsors have relatively limited experience with most molecules when they enter Phase 3.
3+
Most drugs entering the AD drug-development pipeline have failed; only one agent has been approved since 2004 (memantine). The failure rate since 2002 (excluding agents currently in Phase 3) is 99.6%. Currently, 108 trials of AD therapies represent 94 unique agents. This is a relatively small number of test compounds. The small number of agents in Phase 1 is particularly concerning, as it suggests that relatively few drugs are entering the AD drug-development process. Repurposed agents may enter the pipeline at later phases, but it is unlikely that a large number of repurposed agents will be assessed. The AD drug-development pipeline is relatively small, and the rate of success of AD clinical trials is limited. An urgent need exists to increase the number of agents entering the pipeline and progressing successfully toward new therapy for patients with AD.

burun/exercise_0005/img/img1.jpg

1.13 MB
Loading

burun/exercise_0005/img/img2.jpg

4.83 KB
Loading

burun/exercise_0005/img/img3.jpg

241 KB
Loading

burun/exercise_0005/img/img4.jpg

841 KB
Loading

burun/exercise_0005/img_resizer.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
# Date: 11-03-15
4+
# Author: Liang
5+
6+
import os
7+
from PIL import Image
8+
9+
# Set input and output path
10+
img_path = "img/"
11+
new_img_path = "new_img/"
12+
# list all the files in dir
13+
dirs = os.listdir(img_path)
14+
15+
# iphone 5 resolution
16+
iphone_width = 640
17+
iphone_height = 1136
18+
19+
20+
def resizer(img, iwidth, iheight):
21+
im = Image.open(img_path + img)
22+
width, height = im.size
23+
# To decide the ratio to resize
24+
if width > iwidth or height > iheight:
25+
if width / iwidth > height / iheight:
26+
ratio = width / iwidth
27+
else:
28+
ratio = height / iheight
29+
resized_img = im.resize(
30+
(int(width / ratio), int(height / ratio)), Image.ANTIALIAS)
31+
else:
32+
resized_img = im
33+
print("The new size is: ", end=" ")
34+
print(resized_img.size)
35+
resized_img.save(new_img_path + img)
36+
37+
38+
for img in dirs:
39+
resizer(img, iphone_width, iphone_height)

burun/exercise_0005/new_img/img1.jpg

157 KB
Loading

burun/exercise_0005/new_img/img2.jpg

6.08 KB
Loading

burun/exercise_0005/new_img/img3.jpg

73 KB
Loading

burun/exercise_0005/new_img/img4.jpg

14.3 KB
Loading

burun/exercise_0005/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pillow==2.7.0

rahulgsalecha/0001/calculator.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#simple calculator
2+
3+
#define functions
4+
5+
def add(x,y):
6+
return x + y
7+
8+
def subtract(x,y):
9+
return x-y
10+
11+
def multiply(x,y):
12+
return x*y
13+
14+
def divide(x,y):
15+
return x/y
16+
17+
#take input from the user
18+
print("Select Operation:")
19+
print("1.Add")
20+
print("2.Subtract")
21+
print("3.Multiply")
22+
print("4.Divide")
23+
24+
choice = int(input("enter choice(1/2/3/4):"))
25+
26+
num1 = int(input("Enter first number: "))
27+
num2 = int(input("Enter second number: "))
28+
29+
if choice == 1:
30+
print(num1,"+",num2,"=", add(num1,num2))
31+
elif choice == 2:
32+
print(num1,"-",num2,"=", subtract(num1,num2))
33+
elif choice == 3:
34+
print(num1,"*",num2,"=", multiply(num1,num2))
35+
elif choice == 4:
36+
print(num1,"/",num2,"=", divide(num1,num2))
37+
else:
38+
print("Invalid input")

rahulgsalecha/0001/result.txt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
TESTING$ python calculator.py
2+
Select Operation:
3+
1.Add
4+
2.Subtract
5+
3.Multiply
6+
4.Divide
7+
enter choice(1/2/3/4):1
8+
Enter first number: 3
9+
Enter second number: 2
10+
(3, '+', 2, '=', 5)
11+
TESTING$ python calculator.py
12+
Select Operation:
13+
1.Add
14+
2.Subtract
15+
3.Multiply
16+
4.Divide
17+
enter choice(1/2/3/4):2
18+
Enter first number: 2
19+
Enter second number: 3
20+
(2, '-', 3, '=', -1)
21+
TESTING$ python calculator.py
22+
Select Operation:
23+
1.Add
24+
2.Subtract
25+
3.Multiply
26+
4.Divide
27+
enter choice(1/2/3/4):3
28+
Enter first number: 5
29+
Enter second number: 6
30+
(5, '*', 6, '=', 30)
31+
TESTING$ python calculator.py
32+
Select Operation:
33+
1.Add
34+
2.Subtract
35+
3.Multiply
36+
4.Divide
37+
enter choice(1/2/3/4):4
38+
Enter first number: 4
39+
Enter second number: 2
40+
(4, '/', 2, '=', 2)
41+
TESTING$ python calculator.py
42+
Select Operation:
43+
1.Add
44+
2.Subtract
45+
3.Multiply
46+
4.Divide
47+
enter choice(1/2/3/4):1
48+
Enter first number: -1
49+
Enter second number: -1
50+
(-1, '+', -1, '=', -2)
51+
TESTING$ python calculator.py
52+
Select Operation:
53+
1.Add
54+
2.Subtract
55+
3.Multiply
56+
4.Divide
57+
enter choice(1/2/3/4):2
58+
Enter first number: -1
59+
Enter second number: -1
60+
(-1, '-', -1, '=', 0)
61+
TESTING$ python calculator.py
62+
Select Operation:
63+
1.Add
64+
2.Subtract
65+
3.Multiply
66+
4.Divide
67+
enter choice(1/2/3/4):3
68+
Enter first number: 0
69+
Enter second number: 0
70+
(0, '*', 0, '=', 0)
71+
TESTING$ python calculator.py
72+
Select Operation:
73+
1.Add
74+
2.Subtract
75+
3.Multiply
76+
4.Divide
77+
enter choice(1/2/3/4):2
78+
Enter first number: 1
79+
Enter second number: 1
80+
(1, '-', 1, '=', 0)
81+
TESTING$ python calculator.py
82+
Select Operation:
83+
1.Add
84+
2.Subtract
85+
3.Multiply
86+
4.Divide
87+
enter choice(1/2/3/4):4
88+
Enter first number: 0
89+
Enter second number: 0
90+
Traceback (most recent call last):
91+
File "calculator.py", line 36, in <module>
92+
print(num1,"/",num2,"=", divide(num1,num2))
93+
File "calculator.py", line 15, in divide
94+
return x/y
95+
ZeroDivisionError: integer division or modulo by zero
96+
TESTING$

0 commit comments

Comments
 (0)