练习1 2019-3-19
# 写一个函数实现99乘法表 def x99(x):
if x >=1 and x <=9:
line = 1
while line <= x:
start=1
while start <= line:
print('{0}*{1}={2}'.format(start,line,start*line),end=' ')
start+=1
print()
line+=1
else:
print('参数在1-9的正整数范围内!')
# 调用函数
x99(9)

练习2 2019-3-19
# 1到4能组成多少个互不相同且不重复数字的三位数?分别是?

for x in range(1,5):
for y in range(1,5):
for z in range(1,5):
if x != y and y != z and x != z:
print(x,y,z)
练习3 2019-3-19
# 计算两个列表对应相加的和,输出一个新的列表
a = [1,2,3]
b = [4,5,6]
c = []
for i in range(len(a)):
c.append(a[i]+b[i])
print(c)

 练习4 2019-3-19

# 输出一个三角形
def sjx(x):
for i in range(1,x):
print("*"*i)
sjx(4)
print('-'*50) #输出一个空心正方形
def zfx1(x):
print("*"*x)
for i in range(x-2):
print("*"+" "*(x-2)+"*")
print('*'*x)
zfx1(4)
print('-'*50) #输出一个实心正方形
def zfx2(x):
for i in range(x):
print("*"*x)
zfx2(4)
print("-"*50)
练习5 2019-3-19
# 1、一个不超过5位数的正整数,判断位数,且输出个十百千万位上的数
num = int(input("不超过5位数的正整数: "))
n = str(num)
# 按转字符串方式去获取
if len(n) > 5:
print("请输入一个不超过5位数的正整数!")
else:
for i in n[::-1]:
print(i)
print('-'*50)
# 按数字去计算获取
# for i in range(len(n)):
# print(num%10)
# num = num//10
# 2、输入一个数。计算出这个数以内的整数之和
def sum(x):
s1 = 0
for i in range(x+1):
s += i
print(s)
sum(5)
# 3、求可用被17整除的所有三位数
n = []
for i in range(99,1000):
if i % 17==0:
n.append(i)
print(n)

练习6 2019-3-19

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/3/19 17:18
# @Author : wangdecheng
# @Software: PyCharm import time,datetime # 输入年月日,判断这一天是这一年中的第几天?
# 方法1
# y = int(input('year:\n'))
# m = int(input('month:\n'))
# d = int(input('day:\n')) # targetDay = datetime.date(y, m, d)
# dayCount = targetDay - datetime.date(targetDay.year - 1, 12, 31)
# print('%s是%s年的第%s天。' % (targetDay, y, dayCount.days)) # 78天 # 方法2
a=[[31,28,31,30,31,30,31,31,30,31,30,31],
[31,29,31,30,31,30,31,31,30,31,30,31]] #a[0]普通年的月天数,a[1]闰年的月天数
year=int(input("年:"))
month = int(input("月:"))
day = int(input("日:"))
sum=0
if (year%4==0 and year%100!=0)or year%400==0:
for i in range(1,month):
sum=sum+a[1][i]
else:
for i in range(1,month):
sum=sum+a[0][i]
sum=sum+day
print("{}年{}月{}日是这一年的第{}天".format(year,month,day,sum))

 

Python每日练习汇总的更多相关文章

  1. Python每日一练(1):计算文件夹内各个文章中出现次数最多的单词

    #coding:utf-8 import os,re path = 'test' files = os.listdir(path) def count_word(words): dic = {} ma ...

  2. python每日一函数 - divmod数字处理函数

    python每日一函数 - divmod数字处理函数 divmod(a,b)函数 中文说明: divmod(a,b)方法返回的是a//b(除法取整)以及a对b的余数 返回结果类型为tuple 参数: ...

  3. Python IDLE快捷键汇总

    Python IDLE快捷键汇总 在Options→configure IDLE→keys,查看现存的快捷键,也可以配置选择快捷 编辑状态时: Ctrl+Shift+space(默认与输入法冲突,修改 ...

  4. PYTHON资源入口汇总

    Python资源入口汇总 官网 官方文档 教程和书籍 框架 数据库 模板 工具及第三方包 视频 书籍 博客 经典博文集合 社区 其他 整理中,进度30% 官网 入口 官方文档 英文 document ...

  5. python每日一练:0007题

    第 0007 题: 有个目录,里面是你自己写过的程序,统计一下你写过多少行代码.包括空行和注释,但是要分别列出来. # -*- coding:utf-8 -*- import os def count ...

  6. [python每日一练]--0012:敏感词过滤 type2

    题目链接:https://github.com/Show-Me-the-Code/show-me-the-code代码github链接:https://github.com/wjsaya/python ...

  7. Python 每日一练 | Flask 实现半成品留言板

    留言板Flask实现 引言 看了几天网上的代码,终于写出来一个半成品的Flask的留言板项目,为什么说是半成品呢?因为没能实现留言板那种及时评论刷新的效果,可能还是在重定向上有问题 或者渲染写的存在问 ...

  8. Python 每日一练(5)

    引言 Python每日一练又开始啦,今天的专题和Excel有关,主要是实现将txt文本中数据写入到Excel中,说来也巧,今天刚好学校要更新各团支部的人员信息,就借此直接把事情做了 主要对于三种数据类 ...

  9. Python 每日一练(4)

    引言 今天继续是python每日一练的几个专题,主要涵盖简单的敏感词识别以及图片爬虫 敏感词识别 这个敏感词的识别写的感觉比较简单,总的概括之后感觉功能可以简略成if filter_words in ...

随机推荐

  1. JsonP的实现原理?

    动态创建script标签,通过script标签中的src跨域属性,连接对方接口,并将回调函数通过接口传递给对方,对方服务器在准备好数据后再通过调用回调函数并以传递参数的方式将数据返回来.

  2. 活代码LINQ——01

    序言 此系列的所有代码都是运行在Win 7 64位 + Visual Basic 2008 Express Edition的环境中 之所以学习List集合类,是因为我们先前学习的数组自身的缺陷: 1. ...

  3. ShellExecute, WinExec与CreateProcess

    0x01  ShellExecute ShellExecute的功能是运行一个外部程序(或者是打开一个已注册的文件.打开一个目录.打印一个文件等等),并对外部程序有一定的控制.  函数原型: Shel ...

  4. 简单hibernate框架测试

    -jar包 -日志配置文件: -实体类: package cn.itcast.domain; public class Customer { private Long cust_id; //客户编号 ...

  5. 数列全排列问题----递归实现--JAVA

    public class PaiLie { /** * @param args */ public static void main(String[] args) { PaiLie p=new Pai ...

  6. springboot入门学习-helloworld实例

    今天学习了springboot,发现使用springboot创建项目确实非常方便,创建第一个springboot项目之前先看一下下面两个问题. 一.什么是springboot? Spring Boot ...

  7. Qt笔记之QGADGET

    QGADGET宏类似于Q_OBJECT宏,是一个万能容器,至于这个宏所实现的功能,我也不懂,Q_OBJECT宏的功能到时了解一些,我想他们应该差不多,要想使用从Q_OBJECT继承来的类,就得在一开始 ...

  8. SharePoint Framework解决方案管理参考(一)

    博客地址:http://blog.csdn.net/FoxDave 使用SPFx,你的企业可以轻松构建解决方案跟Office 365和SharePoint Online集成.SPFx解决方案基于现代w ...

  9. selenium中切换浏览器不同tab 的操作

    from selenium import webdriverimport timedriver=webdriver.Chrome()driver.get('http://ui.imdsx.cn/uit ...

  10. ubuntu 18.04启动samba图形管理界面

    启动samba图形界面管理器出现错误: Failed to load module "canberra-gtk-module" 或 SystemError: could not o ...