ZKX's LAB

python 编写键盘输入 编写Python程序,从键盘输入直角三角形两直角边a,b,求斜边c,并输出.

2020-10-05知识8

编写Python程序,从键盘输入直角三角形两直角边a,b,求斜边c,并输出.

编写一个Python程序,用户从键盘输入一个年份,程序输出此年份的中国生肖。 year_input=int(input(\"请输入年份:\"))if year_input>;=1000:SymbolicAnimals=year_input%12if SymbolicAnimals=0:print(\"{}年是:申(猴)7a686964616fe78988e69d8331333431373862\".format(year_input))elif SymbolicAnimals=1:print(\"{}年是:酉(鸡)\".format(year_input))elif SymbolicAnimals=2:print(\"{}年是:戌(狗)\".format(year_input))elif SymbolicAnimals=3:print(\"{}年是:亥(猪)\".format(year_input))elif SymbolicAnimals=4:print(\"{}年是:子(鼠)\".format(year_input))elif SymbolicAnimals=5:print(\"{}年是:丑(牛)\".format(year_input))elif SymbolicAnimals=6:print(\"{}年是:寅(虎)\".format(year_input))elif SymbolicAnimals=7:print(\"{}年是:卯(兔)\".format(year_input))elif SymbolicAnimals=8:print(\"{}年是:辰(龙)\".format(year_input))elif SymbolicAnimals=9:print(\"{}年是:巳(蛇)\".format(year_input))elif SymbolicAnimals=10:print(\"{}年是:午(马)\".format(year_input))elif SymbolicAnimals=11:print(\"{}年是:未(羊)\".format(year_input))else:print(\"请输入大于4位数的年份\")

python如何获得键盘输入,ytho中获取键盘输入提供了两个函数,一个是raw_iut,一个是iut,这两个函数的区别在于raw_iu在ytho3之前使用,iut在ytho3及以上的版本使用。

求ptqt+python编写的计算器程序,支持键盘输入,急用,谢谢 #。usr/bin/env pythonCopyright(C)2010 Riverbank Computing Limited.Copyright(C)2010 Nokia Corporation and/or its subsidiary(-ies).All rights reserved.This file is part of the examples of PyQt.QT_BEGIN_LICENSE:BSD$You may use this file under the terms of the BSD license as follows:Redistribution and use in source and binary forms,with or withoutmodification,are permitted provided that the following conditions aremet:Redistributions of source code must retain the above copyrightnotice,this list of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyrightnotice,this list of conditions and the following disclaimer inthe documentation and/or other materials provided with thedistribution.Neither the name of Nokia Corporation and its Subsidiary(-ies)northe names of its contributors may be used to endorse or promoteproducts derived from this software without specific prior writtenpermission.THIS SOFTWARE IS PROVIDED BY 。

如何用python编写程序,从键盘上任意输入两个数,交换两个数并输出?

python从键盘输入一个整数值n,编程求它的所有因子之和,规定n不大于1000 n=int(input(\"please input a integer n:\"))result=0for i in range(1,n):if n%i=0:result+iprint(\"the factor of n sum is:%d\"%result)

用Python,从键盘任意输入一个年,计算这个年是多少天。比如:输入2019年,要首先判断是否闰年 def leap_year_or_not(year):世纪闰年2113:能被400整除的为世5261纪闰年。普通闰年:能被4整除但不能被100整除的年4102份为普1653通闰年。闰年共有366天,其他年只有365天。if int(year)%400=0:return Trueelif int(year)%100。0 and int(year)%4=0:return Trueelse:return Falsedef calculate_days_of_year(year):leap=leap_year_or_not(year)if leap:days=366run=\"是else:days=365run=\"不是print(\"{}年{}闰年,有{}天。.format(year,run,days))if_name_=\"_main_\":print(\"输入年份:\")n=input()calculate_days_of_year(n)运行上述代码,输入2019回车,得到以下结果:

随机阅读

qrcode
访问手机版