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 ...
随机推荐
- nginx之历史回溯
前言 nginx是一个web应用及反向代理工具,由一名俄罗斯程序员(Igor)发明的:NGINX是一个免费的,开源的高性能HTTP服务器和反向代理,以及IMAP / POP3代理服务器. NGINX以 ...
- Jpofiler
参考链接: https://blog.csdn.net/u010638673/article/details/81703942
- 惠普电脑win10关闭自动调节亮度
自动调节亮度真的太烦人了,突然从亮的画面变暗,又从暗的亮度变量,眼睛受不了.但是试了很多种方法都不行. 方法 第一种: 有一些电脑是有在设置--->显示界面--->有一个 关闭自动调节 按 ...
- vue中如何在本地导入js文件
import {setStore,setUser,getStore,removeStore} from "../../../public/localstory" 在导入js文件时, ...
- 深入理解windows 消息机制
深入理解Windows消息机制 今天我们来学一学Windows消息机制,我们知道在传统的C语音程序中,当我们需要打开一个文件时,我们可以调用fopen()函数,这个函数最后又会调用操作系统提供的函数以 ...
- VS生成垃圾文件清理
@echo Off del /s /a *.txt *.exe *.suo *.ncb *.user *.dll *.pdb *.netmodule *.aps *.ilk 2>nul FOR ...
- for实例
#-*- coding:utf-8 *-* salary = 5000 shop_list = [('iphone',9000),('mac book',10000),('python book',9 ...
- iomanip、cstring、string、sstream
#include<iomanip> 控 制 符 作 用 ...
- Go语言实现:【剑指offer】数值的整数次方
该题目来源于牛客网<剑指offer>专题. 给定一个double类型的浮点数base和int类型的整数exponent.求base的exponent次方. 保证base和exponent不 ...
- Go语言实现:【剑指offer】序列化二叉树
该题目来源于牛客网<剑指offer>专题. 请实现两个函数,分别用来序列化和反序列化二叉树. 二叉树的序列化是指:把一棵二叉树按照某种遍历方式的结果以某种格式保存为字符串,从而使得内存中建 ...