首页 > 编程知识 正文

python学习日03作业(大学python作业)

时间:2023-12-05 19:35:22 阅读:312371 作者:QICI

本文目录一览:

  • 1、Python的几个编程作业..求教TAT刚开始学....
  • 2、Python作业题求解
  • 3、Python作业题目
  • 4、学计算机的同学帮看一个python入门的作业?

Python的几个编程作业..求教TAT刚开始学....

作业要自己做

#!/usr/bin/env python

print '''I have 3 kinds of fruit:

apple: $1.29/lb

grage: $2.29/lb

orange: $1.5/lb'''

choice = raw_input('Which one do you want? ')

if choice == 'grape':

weight = float(raw_input('Ok, grape. How many pounds do you want? '))

print 'the cost is', round(weight*2.29,2)

elif choice == 'apple':

weight = float(raw_input('Ok, apple. How many pounds do you want? '))

print 'the cost is', round(weight*1.29,2)

elif choice == 'orange':

weight = float(raw_input('Ok, orange. How many pounds do you want? '))

print 'the cost is', round(weight*1.5,2)

else:

print 'Sorry, we don't have that.'

#!/usr/bin/env python

def smallest(x,y,z):

temp = y if yz else z

return x if xtemp else temp

a = float(raw_input('Enter the 1st number: '))

b = float(raw_input('Enter the 2nd number: '))

c = float(raw_input('Enter the 3rd number: '))

print smallest(a,b,c),'is the smallest.'

#!/usr/bin/env python

left = int(raw_input('Enter the beginning integer: '))

right = int(raw_input('Enter the ending integer: '))

print ("All the integers between %d and %d that are divisible by both 3 and 7 are:" %(left,right))

for i in range(left,right+1):

if i%21==0:

print i,

Python作业题求解

Print = input("请输入需要强调的话:")

Print = Print + "!"

number = int(input("请输入要重复的次数:"))

print(Print * number)

Python作业题目

你好的!

我给你做一下第17 题:别的问题需要答案的话,挨个提问,否则没人一下给你回答那么多的问题

import math

 

 

def is_prime(n):  # 简化问题,先利用函数判断是否为质数

    if n == 1:  # =是赋值,==才是判断,切记切记

        return False

    for i in range(2, int(math.sqrt(n))+1):  # 质数判断条件,注意+1

        if n % i == 0:

            return False

    return True

 

 

primes = []

name = int(input())

if is_prime(i) is True:  # bool值用is判断

   print('the input number is prime number;')

else:

   print('the input number is not a prime number;')

学计算机的同学帮看一个python入门的作业?

编写程序,从键盘上输入三个数字,用输入的第一个数字除以第二个数字,得到的结果和第三个数字相加,在这个过程中注意要捕获异常,根据错误类型去进行异常处理,如果没有触发异常的话,要输出最后的计算结果,程序的最后要输出提示语:程序执行结束。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。