• python Days1


    python代码编写使用英文输入法

    控制台的读取和输入:

    input输入进去的是字符串

    eval

    在jupyter用shift+tab跳出解释文档

    运算符:

    +:加

    -:减

    *:乘

    /:除

    //:整除

    **:指数幂

    %:取余

    增强型赋值运算:

    +=:自加

    -=:自减

    *=:自乘

    /=:自除

    代码:

    celsius=float(input('Enter a degree in Celsius:'))
    fahrenheit = (9 / 5) * celsius + 32
    print("{0} Celsius is {1} Fahrenheit" .format(celsius,fahrenheit))

    代码:

    import math
    radius,length=eval(input('Enter the radius and length of a cylinder:'))
    area = radius **2 * math.pi
    volume = area * length
    print("The area is {0}".format("%.4f"% area))
    print("The volume is {0}".format("%.1f"% volume))

    代码:

    feet=float(input('Enter a value for feet:'))
    meters=feet * 0.305
    print("{0} feet is {1} meters".format(feet,meters))

    代码:

    water=float(input('Enter the amount of water in kilograms:'))
    initialtemperature=float(input('Enter the initial temperature:'))
    finaltemperature=float(input('Enter the final temperature:'))
    Q = water * (finaltemperature - initialtemperature) * 4184
    print("The energy needed is ",Q)

    代码:

    balance,interestrate=eval(input('Enter balance and interest rate (e.g., 3 for 3%):'))
    interest=balance * (interestrate / 1200)
    print("The interest is {0}".format("%.5f"%interest))

    代码:

     v0,v1,t=eval(input('Enter v0,v1,and t:'))
    a=(v1 - v0) / t
    print("The average acceleration is {0}" .format("%.4f"% a))

    代码:

    number=float(input("Ener the monthly saving amount :"))
    number1=0
    for i in range(6):
        number1=(number+number1) * (1 + 0.00417)
    print("After the sixth month,the account value is {0}".format("%.2f"% number1))

    代码:

     number=float(input("Enter a number between 0 and 1000:"))
    bai=int(number/100)
    shi=int(number/10%10)
    ge=int(number%10)
    he=bai+shi+ge
    print("The sum of the digits is ",he)

    体会:

    通过初时Python以及对他的语言元素的认识,对于python有了很深的印象

  • 相关阅读:
    C# 使用NPOI 实现Excel的简单导入导出
    C# 根据Excel模版导出文件
    移动通信第九组网络抓包作业
    武金龙老师的教导(第9小组)
    【Python核心编程笔记】一、Python中一切皆对象
    自己喜欢的几个前端框架
    2018-1-6-个人博客、博客园、微信公众号、Github、本地同步写博客
    2018-1-6-IDEA快速代码生成
    CodeMirror动态修改代码(关键: editor.getDoc().setValue(data); editor.refresh();)
    FaceId枚举表(用于VBA的加载项)
  • 原文地址:https://www.cnblogs.com/huangchuan/p/11272641.html
Copyright © 2020-2023  润新知