python練習
#登录,账户密码储存在文件中,限制登录 count = 0 for i in range(3):
b = input("账号:")
c = b + "," + input("密码:")+"\n" passwd_f = open('D:\python\password_f.txt', 'r')
text = passwd_f.readlines()
for j in range(len(text)):
if text[j] == b + "\n":
print("----账号已经被锁定----")
exit() passwd = open('D:\python\password.txt', 'r')
text = passwd.readlines()
for h in range(len(text)):
if text[h] == c:
print("------欢迎你------")
exit() print("--密码或账户错误--")
passwd.close()
else:
print("--账户已经被锁定--")
passwd_f = open('D:\python\password_f.txt', 'a')
passwd_f.write(b + "\n")
passwd_f.close()
#username = input("账号:")
#password = input("密码:")
打印九九乘法表
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
num_h=1
while num_h<=9:#循環h行
temp=1
while temp<=num_h: #循環l列
print(str(num_h) + "*" + str(temp)+"="+ str(num_h*temp),end=" ")#打印不換行
temp =temp+1
print() #換行
num_h+=1
***************************************************************************************************
隨機輸入成績判斷等級
score =int(input("score:"))
if score>90:
print("A")
elif score>80:
print("B")
elif score>70:
print("c")
else:
print("D")
*************************************************************************************************
打印星星
****
****
****
****
h=int(input("chang:"))#輸入高度
l=int(input("kuan:"))#輸入寬度
num_h=1
while num_h<=l:#循環h行
num_l=1
while num_l<=h: #循環l列
print("*",end="")#打印不換行
num_l+=1
print() #換行
num_h+=1
************************************************************************************
打印星星
*
**
***
****
h=int(input("chang:"))#輸入高度
num_h=1
while num_h<=h:#循環h行
temp=num_h
while temp>0: #循環l列
print("*",end="")#打印不換行
temp =temp-1
print() #換行
num_h+=1
**********************************************************************************************
比大小
a=input("a:")
b=input("b:")
c=input("c:")
sum=""
if a>b:
sum=a
if sum>c:
print("max is",a)
else:
print("max is ",c)
else:
sum=b
if sum>c:
print("max is",b)
else:
print("max is ",c)
**************************************************************************************
猜年龄
age_of_princal=56
while True:
guess_age=int(input(">>:"))
if guess_age==age_of_princal:
print("yes,you got it")
break #跳出程序
elif guess_age>age_of_princal:
print("should try smaller....")
else:
print("try bigger....")
print("end")
*************************************************************************************************************
python練習的更多相关文章
- [心得] 如何利用liquibase進行資料庫版本控制 - 實際練習
透過上一篇的基本觀念介紹,希望大家應該有一點點感覺了! 這篇我們就來做個簡單的版本演練,加深印象吧! 我使用的環境如下 System : Windows 7 Database : SQL Server ...
- [Java] 練習用對戰小遊戲
繼承.介面自我練習時所建立的小遊戲,一開始輸入名稱來建立對戰腳色,之後以輸入招式號碼的方式互相打鬥,最後沒血的一方就輸了. 人物種族 abstract public class Human { int ...
- [转]2010 Ruby on Rails 書單 與 練習作業
原帖:http://wp.xdite.net/?p=1754 ========= 學習 Ruby on Rails 最快的途徑無非是直接使用 Rails 撰寫產品.而這個過程中若有 mentor 指導 ...
- [Python學習筆記] 使用xlwings 插入註解 (forked 版本)
到今天為止 xlwings 還沒有插入註解的功能 去原始開發者的 Github Pull Requests 他說之前有人有建議要加入這個功能 但他還沒更新~ 如果需要使用 Python 來插入註解的話 ...
- python 學習深淺拷貝、集合、、作用域、函數
python 學習深淺拷貝.集合..作用域.函數 2020開年新冠肺炎流行大部分人員.工廠.單位無法復工生產,人員隔離每天外出都要戴口罩,在家隔離期間悶壞了感覺把半年的口糧都幹掉了,嚴重考察大家的資本 ...
- [Python學習筆記] 利用 Python在Excel 插入註解
用Python 來處理excel 檔 用過了 openpyxl 還有 pyexcel目前覺得除了讀寫如果還要使用另外的功能 (像是讀取格子裡的公式)可以用 xlwings 他的首頁標題 " ...
- [Python學習筆記] 抓出msg信件檔裡的附件檔案
想要把msg信件檔案的附件抓出來做處理,找到了這個Python 模組 msg-extractor 使用十分容易,但是這個模組是要在terminal裡執行,無法直接打在IDLE的編輯器上 所以稍微做了修 ...
- [Python學習筆記] 在Centos上安裝 Django
曾在模擬器跟Digital Ocean上安裝成功,我在 Digital Ocean上的是CentOS 7 x64,模擬器的則是Centos 6.雖然Centos 本身已經裝好 Python 但是是2. ...
- 流暢的python學習-3
一.文件操作 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Apr 23 20:59 ...
随机推荐
- 保存网页内容到excel
from selenium import webdriverfrom time import sleepfrom selenium.common.exceptions import NoSuchEle ...
- mybatis入门案例分析
mybatis入门案例分析 一.设计模式分析 public class MybatisTest { public static void main(String[] args) throws Exce ...
- LeetCode 677. Map Sum Pairs 键值映射(C++/Java)
题目: Implement a MapSum class with insert, and sum methods. For the method insert, you'll be given a ...
- Ansi、Unicode、UTF8字符串之间的转换和写入文本文件
转载请注明出处http://www.cppblog.com/greatws/archive/2008/08/31/60546.html 最近有人问我关于这个的问题,就此写一篇blog Ansi字符串我 ...
- selenium窗口截图操作
selenium窗口截图操作 使用背景:在自动化测试过程中,可能遇到执行错误情况,那么怎么样及时捕获出错信息/界面? 可以使用 get_screenshot_as_file(self,filenam ...
- vagrant相关
无法挂载共享目录,报错如下 Vagrant was unable to mount VirtualBox shared folders. This is usually because the fil ...
- HDU_5456_数位dp
http://acm.hdu.edu.cn/showproblem.php?pid=5456 转化成a=b+c,dp[i][a][b][c]表示剩余i木棒,a是否有进位,b是否首尾,c是否首位,注意每 ...
- 《C# 爬虫 破境之道》:第二境 爬虫应用 — 第六节:反爬策略研究
之前的章节也略有提及反爬策略,本节,我们就来系统的对反爬.反反爬的种种,做一个了结. 从防盗链说起: 自从论坛兴起的时候,网上就有很多人会在论坛里发布一些很棒的文章,与当下流行的“点赞”“分享”一样, ...
- Ambari HDP 下 SPARK2 与 Phoenix 整合
1.环境说明 操作系统 CentOS Linux release 7.4.1708 (Core) Ambari 2.6.x HDP 2.6.3.0 Spark 2.x Phoenix 4.10.0-H ...
- VFP 用 SPT 来发布一条 SELECT 到一个新的 SQL Server 表
为了发布一条 SQL SELECT 语句来创建一个新的 SQL Server 表, SQL Server 数据库的 select into/bulkcopy 选项必须是可用的. 在默认情况下, 对于 ...