Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2563644
Initial commit
Yixiaohan Sep 4, 2014
98b9d7b
show-me-the-code first commit
Yixiaohan Sep 4, 2014
0d5f62c
fix 引用格式
Yixiaohan Sep 4, 2014
32ad563
add 敏感词语过滤题目
Yixiaohan Sep 4, 2014
963c079
add 简易爬虫,爬图片
Yixiaohan Sep 10, 2014
181debd
fix 0013 url
Yixiaohan Sep 11, 2014
04253b4
fix 0013 url 格式
Yixiaohan Sep 11, 2014
164c51b
Update README.md
Yixiaohan Sep 11, 2014
33c70ab
add 0014 txt content to Excel
Yixiaohan Sep 12, 2014
1b3e566
add 14 and 15, txt content to excel
Yixiaohan Sep 12, 2014
698e707
add 16 Tencent webgame dev Excel convert to xml
Yixiaohan Sep 12, 2014
dfe7274
fix format
Yixiaohan Sep 12, 2014
29b9376
fix format
Yixiaohan Sep 12, 2014
d516216
fix random generate character
Yixiaohan Sep 12, 2014
9d6ba69
add 0018 and 0019 Excel convert to xml
Yixiaohan Sep 16, 2014
2c2b8c4
add China unicom bill
Yixiaohan Oct 31, 2014
11665b0
add python password encryption
Yixiaohan Nov 12, 2014
ffeb5c9
update format & add guide
horx Dec 1, 2014
531fff3
add Show Me the Code Python version
Yixiaohan Dec 3, 2014
3cfc3c4
add desc
Yixiaohan Dec 3, 2014
56ed5fe
Update README.md
Yixiaohan Dec 3, 2014
eab4329
修改 Pull Request 描述信息到 组织仓库里
Yixiaohan Dec 16, 2014
8db2641
修改 XML Excel 阅读资料的顺序,修改错别字
Yixiaohan Dec 16, 2014
dd2fc5c
add web todo application question
Yixiaohan Dec 16, 2014
785fd91
add SpringSide version TodoList
Yixiaohan Dec 16, 2014
a1dd390
Merge remote-tracking branch 'o/master'
horx Dec 17, 2014
c4b6abb
Problem 1
rahulgsalecha Mar 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions rahulgsalecha/0001/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#simple calculator

#define functions

def add(x,y):
return x + y

def subtract(x,y):
return x-y

def multiply(x,y):
return x*y

def divide(x,y):
return x/y

#take input from the user
print("Select Operation:")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")

choice = int(input("enter choice(1/2/3/4):"))

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

if choice == 1:
print(num1,"+",num2,"=", add(num1,num2))
elif choice == 2:
print(num1,"-",num2,"=", subtract(num1,num2))
elif choice == 3:
print(num1,"*",num2,"=", multiply(num1,num2))
elif choice == 4:
print(num1,"/",num2,"=", divide(num1,num2))
else:
print("Invalid input")
96 changes: 96 additions & 0 deletions rahulgsalecha/0001/result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):1
Enter first number: 3
Enter second number: 2
(3, '+', 2, '=', 5)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):2
Enter first number: 2
Enter second number: 3
(2, '-', 3, '=', -1)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):3
Enter first number: 5
Enter second number: 6
(5, '*', 6, '=', 30)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):4
Enter first number: 4
Enter second number: 2
(4, '/', 2, '=', 2)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):1
Enter first number: -1
Enter second number: -1
(-1, '+', -1, '=', -2)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):2
Enter first number: -1
Enter second number: -1
(-1, '-', -1, '=', 0)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):3
Enter first number: 0
Enter second number: 0
(0, '*', 0, '=', 0)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):2
Enter first number: 1
Enter second number: 1
(1, '-', 1, '=', 0)
TESTING$ python calculator.py
Select Operation:
1.Add
2.Subtract
3.Multiply
4.Divide
enter choice(1/2/3/4):4
Enter first number: 0
Enter second number: 0
Traceback (most recent call last):
File "calculator.py", line 36, in <module>
print(num1,"/",num2,"=", divide(num1,num2))
File "calculator.py", line 15, in divide
return x/y
ZeroDivisionError: integer division or modulo by zero
TESTING$