用户:
少年黑客神威查看:0 回复:1 评论:0 创建时间:2022-07-08T11:29:07
【作品展示】

【作品介绍】
1
【作品源代码】
from tkinter import messagebox, simpledialog, Tk
import webbrowser
speak = input()
if speak == 'English':
print('Hello, sir')
a = input('What is your name: ')
if a == 'Tony·Stark':
print('Hello Mr Stark')
else:
print('Hello'+a+'I am Ultron')
while True:
b = input('What do you want to do:')
if b == 'Caesar':
print('Gaius Julius Caesar,(July 13th,100 BC-March 15th, 44 BC) ,Known as Julius Caesar in history.')
print('He was also an outstanding military commander and politician at the end of the Roman Republic now the Mediterranean coast and other regions, and became the founder of the Roman Empire with his superior talents Caesar was born in a noble family and served successively as treasurer, chief priests, chief justice, consul, supervisor, dictator and so on,')
print('In 60 B.C., he secretly formed the first three alliances with Pompeii, Krasu, then became Governor of Gaul, conquered the entire territory of Gaul(\modern France\\), and attacked German and Britain in eight years.')
print('In 49 B.C., he led the army to occupy Rome, defeated Pompey, integrated power into one, exercised dictatorship, and formulated the 《Julian Calendar》. On March 15, 44 B.C., Caesar was assassinated and killed by a member of the Senate led by Brutu at the age of 56. After Caesars death, his nephew, Davidie, the adopted son, defeated Anthony to create the Roman Empire and became the first emperor. ')
print('Basic information:/nChinese name:盖乌斯·尤利乌斯·恺撒,/nEnglish name: Gaius Julius Caesar/Jules Caesar/n')
print('His nationality: Rome/n Date of birth: July 13, 100 B.C./n Date of death: March 15, 44 B.C./nOccupation: Military Commander, Politician, Dictator /nMajor Achievements: The defeat of the Gallic barbarians laid a good foundation for the founding of the Roman Empire\n')
print('Do you know Caesar cipher')
p = input('What do you want attempt:')
if p == 'Yes':
d = input('Is it encrypted or decrypted: ')
if d == ' deciphering':
#输入明文
text = input('Please enter ciphertext:')
#凯撒解密
s = ''
i = 0
while i < len(text):
d = text[i]
if 'd' <= c <= 'z' or 'D' <= c <= 'Z':
d = chr(ord(d) - 3)
elif 'a' <= c <= 'c' or 'A' <= c <= 'C':
d = chr(ord(d) + 23)
s = s + d
i = i + 1
#输出明文
print('Output plain text:' + s)
elif d == '':
#输入明文
text = input('Please enter clear text:')
#凯撒加密
s = ''
i = 0
while i < len(text):
d = text[i]
if 'a' <= c <= 'w' or 'A' <= c <= 'W':
d = chr(ord(d) + 3)
elif 'x' <= c <= 'z' or 'X' <= c <= 'Z':
d = chr(ord(d) - 23)
s = s + d
i = i + 1
#输出密文
print('Output ciphertext:' + s)
if p == 'No':
break
if b == 'Caesar cipher':
d = input('Is it encrypted or decrypted: ')
if d == ' deciphering':
#输入明文
text = input('Please enter ciphertext:')
#凯撒解密
s = ''
i = 0
while i < len(text):
d = text[i]
if 'd' <= c <= 'z' or 'D' <= c <= 'Z':
d = chr(ord(d) - 3)
elif 'a' <= c <= 'c' or 'A' <= c <= 'C':
d = chr(ord(d) + 23)
s = s + d
i = i + 1
#输出明文
print('Output plain text:' + s)
elif d == '':
#输入明文
text = input('Please enter clear text:')
#凯撒加密
s = ''
i = 0
while i < len(text):
d = text[i]
if 'a' <= c <= 'w' or 'A' <= c <= 'W':
d = chr(ord(d) + 3)
elif 'x' <= c <= 'z' or 'X' <= c <= 'Z':
d = chr(ord(d) - 23)
s = s + d
i = i + 1
#输出密文
print('Output ciphertext:' + s)
if b == 'Morse':
print('Samuel Finley Breese Morse,(\April 27, 1791-April 2, 1872\).')
print('A man is a prestigious American painter and father of telegrams. Born on April 27, 1791, in Charleston, Massachusetts, USA. Morse began his career as a painter.')
print('In 1839 he published his first invention, the Morse code. The telegram invented by his peers used Morse code to tran喵it signals, and in 1844 Morse sent the first telegram in human history from Washington to Baltimore.')
print('In the seamless Capitol Building, Morse manipulated the telegraph that he had worked on for more than a decade with his shaking hands. He died in New York on April 2, 1872.')
if b == 'Morse code':
codes = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..',
'E': '.', 'F': '..-.', 'G': '--.', 'H': '....',
'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.',
'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-',
'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..',
'0': '-----', '1': '.----', '2': '..---', '3': '...--',
'4': '....-', '5': '.....', '6': '-....', '7': '--...',
'8': '---..', '9': '----.',
'.': '.-.-.-', ':': '---...', ',': '--..--', ';': '-.-.-.',
'?': '..--..', '=': '-...-', '\'': '.----.', '/': '-..-.',
'!': '-.-.--', '-': '-....-', '_': '..--.-', '"': '.-..-.',
'(': '-.--.', ')': '-.--.-', '$': '...-..-', '&': '....',
'@': '.--.-.', '+': '.-.-.',}
words = input('Please enter an English sentence:')
for s in words:
code = codes.get(s.upper(), s)
print(code, end=' ')
break
if b == 'Nine word guessing':
import random
lives = 9
words = ['pizza', 'fairy', 'teeth', 'shirt', 'otter', 'plane']
secret_word = random.choice(words)
clue = list('?????')
heart_symbol = u'\u27喵'
guessed_word_correctly = False
def update_clue(guessed_letter, secret_word, clur):
index = 0
while index < len(secret_word):
if guessed_letter == secret_word[index]:
clue[index] = guessed_letter
index = index + 1
while lives > 0:
print(clue)
print('Lives left:' + heart_symbol * lives)
guess = input('Guess a letter or the whole word:')
if guess == secret_word:
guessed_word_correctly = True
break
if guess in secret_word:
update_clue(guess, secret_word, clue)
else:
print('Incorrect.You lose a life')
lives = lives - 1
if guessed_word_correctly:
print('You won!The secret word was '
+ secret_word)
else:
print('You lost!The secret word was '
+ secret_word)
break
if b == "Surf the Internet":
d = input('Do you want Baidu or Sogou:')
if d == 'Baidu':
webbrowser.open('https://www.喵/')
if d == 'Sogou':
webbrowser.open('https://www.sogou.com/')
else:
break
if b == "I want Ask Questions":
e = input('Ask:')
if e == 'I want fly':
v = input('Please enter the spacecraft speedkm/s:')
v = float(v)
if v < 7.9:
print('The spacecraft did not reach space speed and could not enter space')
elif v == 7.9:
print('The spacecraft reaches the first co喵ic speed, enters space, and circles the earth')
elif v > 7.9 and v < 11.2:
print('The spacecraft reaches the first co喵ic speed, enters space, and orbits the earth in an elliptical motion')
elif v >= 11.2 and v < 16.7:
print('A spacecraft reaches Second Co喵ic speed, disengages from the gravitational pull of the earth, and orbits the sun')
elif v >= 16.7:
print('The spacecraft reaches the third co喵ic speed, escapes the suns gravitational pull, and flies into interstellar space')
if e == 'I want to test what my body looks like':
mass = float(input('Please enter your weight(kg):'))
height = float(input('Please enter your height(m):'))
bmi = round(mass / height / height)
if bmi < 18.5:
body = 'Thin'
elif 18.5 <= bmi < 24:
body = 'normal'
elif 24 <= bmi < 28:
body = 'overweight'
elif bmi >= 28:
body = 'Obesity'
print(body)
if e == 'I want to see what my results are like':
score = int(input('Please enter your results:'))
if score < 60:
print('Unqualified')
elif 60 <= score <= 69:
print('qualified')
elif 70 <= score <= 89:
print('good')
elif 90 <= score <= 100:
print('excellent')
else:
print('Error Data')
else:
break
if b == 'Information Encryption and Decryption':
def is_even(number):
return number % 2 == 0
def get_even_letters(message):
even_letters = []
for counter in range(0, len(message)):
if is_even(counter):
even_letters.append(message[counter])
return even_letters
def get_odd_letters(message):
odd_letters = []
for counter in range(0, len(message)):
if not is_even(counter):
odd_letters.append(message[counter])
return odd_letters
def swap_letters(message):
letter_list = []
if not is_even(len(message)):
message = message + 'x'
even_letters = get_even_letters(message)
odd_letters = get_odd_letters(message)
for counter in range(0, int(len(message)/2)):
letter_list.append(odd_letters[counter])
letter_list.append(even_letters[counter])
new_message = ''.join(letter_list)
return new_message
def get_task():
task = simpledialog.askstring('Task', 'Do you want to encrypt or decrypt?')
return task
def get_message():
message = simpledialog.askstring('Message', 'Enter the secret message:')
return message
root = Tk()
while True:
task = get_task()
if task == 'encrypt':
message = get_message()
encrypted = swap_letters(message)
messagebox.showinfo('Ciphertext of the secret message is:', encrypted)
elif task == 'decrypt':
message = get_message()
decrypted = swap_letters(message)
messagebox.showinfo('Plaintext of the secret message is:', message)
else:
break
root.mainloop()
elif b == 'switch language':
speak == 'Chinese'
elif speak == 'Chinese':
a = input('你叫什么名字:')
if a == '托尼 斯塔克':
print('你好斯塔克先生,我叫奥创')
else:
print('你好'+a+'我叫奥创')
while True:
b = input('你想干什么:')
if b == '凯撒':
print('盖乌斯·尤利乌斯·恺撒(Gaius Julius Caesar,公元前100年7月13日-公元前44年3月15日) ,史称恺撒大帝,又译盖厄斯·儒略·凯撒,加伊乌斯·朱利叶斯·凯撒等.')
print('他还是罗马共和国(\今地中海沿岸等地区\)末期杰出的军事统帅, 政治家, 并且以其优越的才能成为了罗马帝国的奠基者.恺撒出身贵族, 历任财务官, 祭司长, 喵官, 执政官, 监察官, 喵官等职, ')
print('公元前60年与庞培, 克拉苏秘密结成前三头同盟, 随后出任高卢总督, 在8年的时间里征服了高卢全境(\今法国一带\), 还袭击了日耳曼和不列颠.')
print('公元前49年, 他率军占领罗马, 打败庞培, 集大权于一身, 实行喵统治, 制定了 << 儒略历 >> .公元前44年3月15日, 恺撒遭到以布鲁图所领导的元老院成员喵身亡, 享年56岁, 恺撒喵后, 其甥孙即养子屋大维击败安东尼开创罗马帝国并成为第一位帝国皇帝.')
print('基本信息:中文名称: 盖乌斯·尤利乌斯·恺撒,外文名称: Gaius Julius Caesar/Jules Caesar别名: 恺撒大帝,盖厄斯·儒略·凯撒,加伊乌斯·朱利叶斯·凯撒.')
print('他的国籍: 罗马 出生日期: 公元前 100年7月13日逝世日期: 公元前 44年3月15日 职业: 军事统帅,政治家,喵官主要成就:击败高卢蛮族 为开创罗马帝国打下了良好的基础\n主要对手: 庞培 出生地: 罗马\n信仰: 多神教')
print('代表作品: <>,<>星座: 巨蟹座喵因: 遇刺')
if b == "凯撒密码":
d = input('是加密还是解密:')
if d == '解密':
#输入明文
text = input('请输入密文:')
#凯撒解密
s = ''
i = 0
while i < len(text):
d = text[i]
if 'd' <= c <= 'z' or 'D' <= c <= 'Z':
d = chr(ord(d) - 3)
elif 'a' <= c <= 'c' or 'A' <= c <= 'C':
d = chr(ord(d) + 23)
s = s + d
i = i + 1
#输出明文
print('输出明文:' + s)
elif d == '加密':
#输入明文
text = input('请输入明文:')
#凯撒加密
s = ''
i = 0
while i < len(text):
d = text[i]
if 'a' <= c <= 'w' or 'A' <= c <= 'W':
d = chr(ord(d) + 3)
elif 'x' <= c <= 'z' or 'X' <= c <= 'Z':
d = chr(ord(d) - 23)
s = s + d
i = i + 1
#输出密文
print('输出密文:' + s)
if b == '莫尔斯':
print('塞缪尔·莫尔斯(/Samuel Finley Breese Morse,1791年4月27日—1872年4月2日\).')
print('男,是一名享有盛誉的喵画家,电报之父.1791年4月27日出生在喵马萨诸塞州的查尔斯顿.Morse最初的职业是画家.')
print('1839年他发布了他的第一项发明莫尔斯码.他的同行发明的电报就是运用莫尔斯码来传递信号的,1844年莫尔斯从华盛顿州到巴尔的摩拍发人类历史上的第一份电报.')
print('在座无虚席的国会大厦里,莫尔斯用激动得有些颤抖的双手,操纵着他倾十余年心血研制成功的电报机.1872年4月2日于纽约逝世.')
if b == '莫尔斯码':
codes = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..',
'E': '.', 'F': '..-.', 'G': '--.', 'H': '....',
'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.',
'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-',
'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..',
'0': '-----', '1': '.----', '2': '..---', '3': '...--',
'4': '....-', '5': '.....', '6': '-....', '7': '--...',
'8': '---..', '9': '----.',
'.': '.-.-.-', ':': '---...', ',': '--..--', ';': '-.-.-.',
'?': '..--..', '=': '-...-', '\'': '.----.', '/': '-..-.',
'!': '-.-.--', '-': '-....-', '_': '..--.-', '"': '.-..-.',
'(': '-.--.', ')': '-.--.-', '$': '...-..-', '&': '....',
'@': '.--.-.', '+': '.-.-.',}
words = input('请输入一句英文:')
for s in words:
code = codes.get(s.upper(), s)
print(code, end=' ')
if b == '单词九连猜':
import random
lives = 9
words = ['pizza', 'fairy', 'teeth', 'shirt', 'otter', 'plane']
secret_word = random.choice(words)
clue = list('?????')
heart_symbol = u'\u27喵'
guessed_word_correctly = False
def update_clue(guessed_letter, secret_word, clur):
index = 0
while index < len(secret_word):
if guessed_letter == secret_word[index]:
clue[index] = guessed_letter
index = index + 1
while lives > 0:
print(clue)
print('剩余生命:' + heart_symbol * lives)
guess = input('猜一个字母或整个单词:')
if guess == secret_word:
guessed_word_correctly = True
break
if guess in secret_word:
update_clue(guess, secret_word, clue)
else:
print('你失去了生命')
lives = lives - 1
if guessed_word_correctly:
print('你赢了,单词是 '
+ secret_word)
else:
print('你输了,单词是'
+ secret_word)
if b == "上网":
d = input('你想百度还是搜狗:')
if d == '百度':
webbrowser.open('https://www.喵/')
if d == '搜狗':
webbrowser.open('https://www.sogou.com/')
if b == "我想问问题":
e = input('问吧:')
if e == '我想飞上天':
v = input('请输入 航天器速度km/s:')
v = float(v)
if v < 7.9:
print('航天器未达到宇宙速度,不能进入太空')
elif v == 7.9:
print('航天器达到第一宇宙速度,进入太空,绕地球作圆周运动')
elif v > 7.9 and v < 11.2:
print('航天器达到第一宇宙速度,进入太空,绕地球作椭圆运动')
elif v >= 11.2 and v < 16.7:
print('航天器达到第二宇宙速度,摆脱地球引力,绕太阳运行')
elif v >= 16.7:
print('航天器达到第三宇宙速度,摆脱太阳引力,飞向星际空间')
if e == '我想测试我的体型是什么样的':
mass = float(input('请输入体重(kg):'))
height = float(input('请输入身高(m):'))
bmi = round(mass / height / height)
if bmi < 18.5:
body = '偏瘦'
elif 18.5 <= bmi < 24:
body = '正常'
elif 24 <= bmi < 28:
body = '超重'
elif bmi >= 28:
body = '肥胖'
print(body)
if e == '我想看看我的成绩怎么样':
score = int(input('请输入成绩:'))
if score < 60:
print('不合格')
elif 60 <= score <= 69:
print('合格')
elif 70 <= score <= 89:
print('良好')
elif 90 <= score <= 100:
print('优秀')
else:
print('错误数据')
if b == '加解密':
def is_even(number):
return number % 2 == 0
def get_even_letters(message):
even_letters = []
for counter in range(0, len(message)):
if is_even(counter):
even_letters.append(message[counter])
return even_letters
def get_odd_letters(message):
odd_letters = []
for counter in range(0, len(message)):
if not is_even(counter):
odd_letters.append(message[counter])
return odd_letters
def swap_letters(message):
letter_list = []
if not is_even(len(message)):
message = message + 'x'
even_letters = get_even_letters(message)
odd_letters = get_odd_letters(message)
for counter in range(0, int(len(message)/2)):
letter_list.append(odd_letters[counter])
letter_list.append(even_letters[counter])
new_message = ''.join(letter_list)
return new_message
def get_task():
task = simpledialog.askstring('Task', '你要加密还是解密?')
return task
def get_message():
message = simpledialog.askstring('Message', '输入机密消息:')
return message
root = Tk()
while True:
task = get_task()
if task == '加密':
message = get_message()
encrypted = swap_letters(message)
messagebox.showinfo('Ciphertext of the secret message is:', encrypted)
elif task == '解密':
message = get_message()
decrypted = swap_letters(message)
messagebox.showinfo('Plaintext of the secret message is:', message)
else:
break
root.mainloop()
elif b == '切换语言':
speak == 'English'
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn
少年黑客神威imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8A%A0%E6%B2%B9.gif"alt="emotion_编程猫_加油"
点赞0
评论