python經典程式 python經典程式

2021-10-25 08:50:35 字數 1483 閱讀 9730

輸入輸出

#判斷輸入整數是否在[0,100]之間

num = eval(input("請輸入乙個整數:"))

if num > 100 or num < 0: #判斷[0,100]

print("輸入的整數小於0或大於100")

else:

print("輸入整數在0到100之間(含)")

temps=input(" ")

#斐波拉列數列

a,b=0,1

while a<1000:#輸出不大於1000的序列

print(a,end=',')

a,b=b,a+b

temps=input(" ")

#繪製七彩圓圈

import turtle

colors = ['red','orange','yellow','green','blue','indigo','purple']

for i in range(7):

c = colors[i]

turtle.color(c,c)

turtle.begin_fill()

turtle.rt(360/7)

turtle.circle(50)

turtle.end_fill()

turtle.done()

#繪製五角星

from turtle import *

color('#cc00ff','red')

begin_fill()

for i in range(5):

fd(200)

rt(144)

end_fill()

done()

# caesarencode.py

ptxt = input("請輸入要進行加密的英文: ")

for p in ptxt:

if "a" <= p <= "z":

print(chr(ord("a")+(ord(p)-ord("a")+3)%26), end='')

elif "a" <= p <= "z":

print(chr(ord("a")+(ord(p)-ord("a")+3)%26), end='')

else:

print(p, end='')

ptxt = input(" 請輸入要進行解密的英文: ")

for p in ptxt:

if "a" <= p <= "z":

print(chr(ord("a")+(ord(p)-ord("a")-3)%26), end='')

elif "a" <= p <= "z":

print(chr(ord("a")+(ord(p)-ord("a")-3)%26), end='')

else:

print(p, end='')

print(" 按回車結束程式")

temps=input(" ")

凱撒密碼

>>>l oryh brx!!!

python3經典例題 經典例題 Python

python python開發 python語言 經典例題 python 經典例題 if巢狀 1.使用者輸入賬號 2.使用者輸入密碼 3.判斷使用者的賬號是不是alex 4.如果賬號是alex在繼續判斷密碼是不是alexdsb 5.賬號和密碼都正確提示使用者alex就是乙個dsb 6.如果賬號正確密...

Python的經典入門程式

題目一 輸入一行字元,分別統計字母,數字,空格以及其他字元出現的次數 def test letter 0 space 0 digit 0 other 0 s input please input string for d in s if d.isdigit digit 1 elif d.isalph...

python的幾個經典程式

1.python快速判斷乙個數是否為素數 本程式實現的功能是判斷乙個數是否為素數 n input 請輸入乙個整數 n int n if n 2 print n,是素數 偶數必然不是素數 elif n 2 0 print n,不是素數 else 大於5的素數必然出現在6的倍數的兩側 因為6x 2,6x...