Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added 1-7_practice/00_test/新建日记本文档.jnt
Binary file not shown.
250 changes: 250 additions & 0 deletions 1-7_practice/02_方志强/02_方志强_ex1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1.输入矩形的长与宽,计算矩形面积"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6000\n"
]
}
],
"source": [
"length=100\n",
"width=60\n",
"area=length*width\n",
"print(area)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2.输入一个时间值s,它是距当日午夜的秒值,计算目前的时间,时间按HH:MM:SS格式输出。"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time:23:48:54\n"
]
}
],
"source": [
"s=666\n",
"b=86400\n",
"c=(b-s)//3600\n",
"d=((b-s)-c*3600)//60\n",
"e=((b-s)-c*3600-d*60)\n",
"print(\"Time:%02d:%02d:%02d\"%(c,d,e))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3.如a=1、b=2、c=3、d=0写出下列的逻辑值\n",
"# (1)a>b and b>c or a+b<c\n",
"# (2)a-b<c or b>c and not c\n",
"# (3)not d or b>c+a or a\n",
"# (4)d and b and c>d and a*b>c\n",
"# (5)not(a>b and c>d)\n",
"# (6)a*b>c or b+c>d and not d\n",
"# (7)c+d<=b+d and d<c or 2*b>c\n",
"# (8)d < b or c>a+b+d and b<c+a"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n",
"True\n",
"True\n",
"0\n",
"True\n",
"True\n",
"True\n",
"True\n"
]
}
],
"source": [
"a=1\n",
"b=2\n",
"c=3\n",
"d=0\n",
"print(a>b and b>c or a+b<c)\n",
"print(a-b<c or b>c and not c)\n",
"print(not d or b>c+a or a)\n",
"print(d and b and c>d and a*b>c)\n",
"print(not (a>b and c>d))\n",
"print(a*b>c or b+c>d and not d)\n",
"print(c+d<=b+d and d<c or 2*b>c)\n",
"print(d<b or c>a+b+d and b<c+a)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 4.有一个数x在区间[-5,0]内,写出其条件表达式。"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x>=-5 and x<=0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 5.写出下面表达式的值(设a=1,b=2,c=3,x=4,y=3)\n",
"# (1)a+b>c and b==c\n",
"# (2)not a<b and b not =c or x+y<=3\n",
"# (3)a+(b>=x+y)and c-a and y-x\n",
"# (4) not(x==a) and (y==b) and 0\n",
"# (5) not (a+b)+c-1 and b+c/2\n",
"# (6) a or 1+'a' and b and 'c'"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n",
"False\n",
"-1\n",
"False\n",
"False\n",
"1\n"
]
}
],
"source": [
"a=1\n",
"b=2\n",
"c=3\n",
"x=4\n",
"y=3\n",
"print(a+b>c and b==c)\n",
"print(not (a<b)and (b !=c) or (x+y<=3))\n",
"print(a+(b>=x+y) and c-a and y-x)\n",
"print(not(x==a) and (y==b) and 0)\n",
"print(not (a+b)+c-1 and b+c/2)\n",
"print(a or 1+'a' and b and 'c')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 计算学生成绩"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"数学成绩: 100\n",
"语文成绩: 92\n",
"英文成绩: 95\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"总分: 287.0 平均: 95.66666666666667\n"
]
}
],
"source": [
"math = input(\"数学成绩:\")\n",
"chinese = input(\"语文成绩:\")\n",
"english = input(\"英文成绩:\")\n",
"math = float(math)\n",
"chinese = float(chinese)\n",
"english = float (english)\n",
"sum = math + chinese + english\n",
"print(\"总分:\",sum,\"平均:\",sum/3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading