python文件操作实验报告,python程序设计实验报告

python大作业的详细描述

# encoding=UTF-8  ==>定义Python代码的编码为UTF-8# 石头剪子布 程序# 李忠import random  ==>导入随机生成器 # 定义石头剪子布字典dict = {1:'剪子',2:'石头',3:'布'}  ==>定义一个字典来保存数字和石头剪子布的对应关系 for row in dict:  ==>遍历字典并在Console上面打印出数字和石头剪子布的关系    print '编号:',row,' = ',dict[row] print '您出什么?

'  loop = True   ==>设置loop为True来让下面的while无限循环while loop:  ==>开始无限循环    you = raw_input('请输入编号回车: ')  ==>在Console打印提示    try:  ==>如果下面的代码出现异常就抛出异常        you = int(you)  ==>将用户输入的字符转换成int类型        if you>=1 and you如果你输入的数值大于1并且小于3就停止循环            loop = False        else:  ==>否则继续循环并且打印以下提示            print '请输入 1-3 范围内的编号'    except Exception,e:  ==>如果you = int(you)出现错误(异常)就输出下面的提示语        print '请输入正确的数字编号' dn = random.randint(1,3)  ==>在1到3的范围内随机产生一个数字print '你出:',dict[you]  ==>打印用户输入数字所对应的出手类型print '电脑出:',dict[dn]  ==>打印计算机随机产生的数字对应的出手类型print '结果:', if dn==you:  ==>如果计算机和用户的数值相同    print '平局'elif (you>dn and you-dn==1) or you+2==dn:  ==>如果用户输入的数值比计算机的随机数大1或者用户输入的数值比计算机的随机数小2    print '你胜'else:    print '电脑胜'。

谷歌人工智能写作项目:小发猫

python作业求帮助

#!/usr/bin/env python# -*- coding: utf-8 -*-# File name: parabolic#   Project name: parabolic_equation""".. moduleauthor::.. Module.. name parabolic of procjet parabolic_equation   """from sympy import *import matplotlib.pyplot as pltimport numpy as npdef _filterComplex(inputvalue, description='inputvalue'): try: str(inputvalue).index('I') except ValueError: return False else: return Truedef _checkBool(inputvalue, description='inputvalue'):    """    :param inputvalue: :param description: :return:    """    if not isinstance(inputvalue, bool):        raise TypeError(            'The {0} must be boolean. Given: {1!r}'.format(description, inputvalue))def _checkNumerical(inputvalue, description='inputvalue'): """ :param inputvalue: :param description: :return: """ try: inputvalue + 1 except TypeError: raise TypeError( 'The {0} must be numerical. Given: {1!r}'.format(description, inputvalue))def _drawTowPara(expr_1, expr_2,  inputmin, inputmax ,step=0.1): """ :param expr_1: :param expr_2: :param inputmin: :param inputmax: :param step: :param expr_1_evalwithY: :param expr_2_evalwithY: :return: """ _checkNumerical(inputmin, 'xmin') _checkNumerical(inputmax, 'xmax') _checkNumerical(step, 'step') y1List = [] x1List = [] y2List = [] x2List = [] if expr_1.vertical is True: x1List = np.arange(inputmin, inputmax, step) for x in x1List: y1List.append(expr_1.evaluates_Y(x)) else: y1List = np.arange(inputmin, inputmax, step) for y in y1List: x1List.append(expr_1.evaluates_X(y)) if expr_2.vertical is True: x2List = np.arange(inputmin, inputmax, step) for x in x2List: y2List.append(expr_2.evaluates_Y(x)) else: y2List = np.arange(inputmin, inputmax, step) for y in y2List: x2List.append(expr_2.evaluates_X(y)) (x1List, y1List, '+') (x2List, y2List, '-') ()def _solveCrossing(expr_1, expr_2): """ :param expr_1: :param expr_2: :return: """ x = Symbol('x') y = Symbol('y') print "Given the first expression: {0!r}".format() print "Given the first expression: {0!r}".format() ResultList = solve([, ], [x, y]) Complex = False ResultListTrue = [] for i in range(0, (len(ResultList)),1):  if _filterComplex(ResultList[i][0], 'x') or _filterComplex(ResultList[i][1], 'y'): Complex = True else: ResultListTrue.append(ResultList[i]) if len(ResultListTrue) == 0 and Complex: print "Two hyperbolic do not intersect, and there is imaginary value." elif len(ResultListTrue) == 1: print "Two hyperbolic tangent.:"  print ResultListTrue else: print "Two hyperbolic intersection, and Points are:"  for iterm in ResultListTrue: print itermclass Parabolic(): """ """ def __init__(self, a, b, c, vertical=True): """ :return: """ _checkNumerical(a, 'a') _checkNumerical(b, 'b') _checkNumerical(c, 'c') _checkBool(vertical, 'vertical') self.a = a self.b = b self.c = c self.vertical = vertical self.y = Symbol('y') self.x = Symbol('x') self.xarray = [] self.yarray = [] if vertical is True:  = (self.x**2)*self.a + self.x*self.b + self.c else:  = (self.y**2)*self.a + self.y*self.b + self.c def __repr__(self): """ :return: """ if self.vertical is True: return "The Equation look like: {0!r}".format() else: return "The Equation look like: {0!r}".format() def evaluates_X(self, inputvalue): """ :param inputvalue: :return: """ _checkNumerical(inputvalue, 'y') return (self.y, inputvalue) def evaluates_Y(self, inputvalue): """ :param inputvalue: :return: """ _checkNumerical(inputvalue, 'x') return (self.x, inputvalue) def getArrays(self, inputmin, inputmax, step=1): """ :param inputmin: :param inputmax: :param step: :return: """ _checkNumerical(inputmin, 'xmin') _checkNumerical(inputmax, 'xmax') _checkNumerical(step, 'step') if self.vertical is True: for x in range(inputmin, inputmax, step): self.xarray.append(x) self.yarray.append(self.evaluates_Y(x)) else: for y in range(inputmin, inputmax, step): self.yarray.append(y) self.xarray.append(self.evaluates_X(y)) def drawPara(self, inputmin, inputmax, step=1): """ :param inputmin: :param inputmax: :param step: :return: """ _checkNumerical(inputmin, 'xmin') _checkNumerical(inputmax, 'xmax') _checkNumerical(step, 'step') yList = [] xList = [] if self.vertical is True: xList = np.arange(inputmin, inputmax, step) for x in xList: yList.append(self.evaluates_Y(x)) else: yList = np.arange(inputmin, inputmax, step) for y in yList: xList.append(self.evaluates_X(y)) (xList, yList, '+') ()if __name__ == '__main__': pa1 = Parabolic(-5,3,6) pa2 = Parabolic(-5,2,5, False) print pa1 print pa2 _solveCrossing(pa1, pa2) _drawTowPara(pa1, pa2, -10, 10, 0.1)# 这就是你想要的,代码解决了你的大部分问题,可以求两条双曲线交点,或者直线与双曲线交#点,或者两直线交点. 不过定义双曲线时候使用的是一般式.也也尽可能做了测试,如果有#问题的话,追问吧typescript设置样式

python编程大作业,求教大神,非常急!!!!

求python大作业!!!程序和程序描述都要 30

挺想试一试的,但是你这个问题,让人无从下手,你们老师什么要求?哪怕很含糊也是可以的嘛。

比如“写一个文件搜索函数,用户给定关键字,搜索当前目录和子目录下的所有包含关键字的文件,打印文件的绝对路径”,像这种?会不会过于简单?

python大作业 25

1、大作业要求:设计 Python 语言的简单解释器,满足下面给定的要求。提交源代码(包括 makefile)及设计文 20


相关链接:
1、vue3使用的移动端UI框架,vue3.0 ui组件库
2、element框架百度百科,element框架怎么用
3、电力人工智能的研究与应用,人工智能与电力系统
4、vue父组件向孙子组件传值,vue中父子组件传值方式
5、神经网络应用案例预测法,神经网络算法应用案例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值