TempStr= input ( "请输入带有符号的温度值:" )
if TempStr[ - 1 ] in [ 'F' , 'f' ] :
C= ( eval ( TempStr[ 0 : - 1 ] ) - 32 ) / 1.8
print ( "转换后的温度是{:.2f}C" . format ( C) )
elif TempStr[ - 1 ] in [ 'C' , 'c' ] :
F= 1.8 * eval ( TempStr[ 0 : - 1 ] ) + 32
print ( "转化后的温度是{:.2f}F" . format ( F) )
else :
print ( "输入格式错误" )
请输入带有符号的温度值:22f
转换后的温度是-5.56C
TempStr= input ( "请输入带有符号的温度值:" )
while TempStr[ - 1 ] not in [ 'N' , 'n' ] :
if TempStr[ - 1 ] in [ 'F' , 'f' ] :
C= ( eval ( TempStr[ 0 : - 1 ] ) - 32 ) / 1.8
print ( "转换后的温度是{:.2f}C" . format ( C) )
elif TempStr[ - 1 ] in [ 'C' , 'c' ] :
F= 1.8 * eval ( TempStr[ 0 : - 1 ] ) + 32
print ( "转化后的温度是{:.2f}F" . format ( F) )
else :
print ( "输入格式错误" )
TempStr= input ( "请输入带有符号的温度值:" )
请输入带有符号的温度值:22f
转换后的温度是-5.56C
请输入带有符号的温度值:33F
转换后的温度是0.56C
请输入带有符号的温度值:33c
转化后的温度是91.40F
请输入带有符号的温度值:n
def tempConvert ( ValueStr) :
if TempStr[ - 1 ] in [ 'F' , 'f' ] :
C= ( eval ( TempStr[ 0 : - 1 ] ) - 32 ) / 1.8
print ( "转换后的温度是{:.2f}C" . format ( C) )
elif TempStr[ - 1 ] in [ 'C' , 'c' ] :
F= 1.8 * eval ( TempStr[ 0 : - 1 ] ) + 32
print ( "转化后的温度是{:.2f}F" . format ( F) )
else :
print ( "输入格式错误" )
TempStr= input ( "请输入带有符号的温度值:" )
tempConvert( TempStr)
请输入带有符号的温度值:22f
转换后的温度是-5.56C
import turtle
turtle. setup( 650 , 350 , 200 , 200 )
turtle. penup( )
turtle. fd( - 250 )
turtle. pendown( )
turtle. pensize( 25 )
turtle. pencolor( "purple" )
turtle. seth( - 40 )
for i in range ( 4 ) :
turtle. circle( 40 , 80 )
turtle. circle( - 40 , 80 )
turtle. circle( 50 , 80 / 2 )
turtle. fd( 40 )
turtle. circle( 16 , 180 )
turtle. fd( 40 * 2 / 3 )
turtle. done( )
from turtle import *
setup( 650 , 350 , 200 , 200 )
penup( )
fd( - 250 )
pendown( )
pensize( 25 )
pencolor( "purple" )
seth( - 40 )
for i in range ( 4 ) :
circle( 40 , 80 )
circle( - 40 , 80 )
circle( 40 , 80 / 2 )
fd( 40 )
circle( 16 , 180 )
fd( 40 * 2 / 3 )
turtle. done( )
import turtle
def drawSnake ( radius, angle, length) :
turtle. seth( - 40 )
for i in range ( length) :
turtle. circle( radius, angle)
turtle. circle( - radius, angle)
turtle. circle( radius, angle/ 2 )
turtle. fd( 40 )
turtle. circle( 16 , 180 )
turtle. fd( 40 * 2 / 3 )
turtle. setup( 650 , 350 , 200 , 200 )
turtle. penup( )
turtle. fd( - 250 )
turtle. pendown( )
turtle. pensize( 25 )
turtle. pencolor( "purple" )
drawSnake( 40 , 80 , 4 )
turtle. done( )
TempStr= eval ( input ( "请输不带有符号的温度值:" ) )
Tempsign= input ( "请输入符号:" )
if Tempsign in [ 'F' , 'f' ] :
C= TempStr- 32 / 1.8
print ( "转换后的温度是{:.2f}" . format ( C) )
elif Tempsign in [ 'C' , 'c' ] :
F= 1.8 * TempStr+ 32
print ( "转化后的温度是{:.2f}" . format ( F) )
else :
print ( "输入格式错误" )
请输不带有符号的温度值:22
请输入符号:f
转换后的温度是4.22
money= input ( "请输入您要转换的钱数(R r or M m): " )
if money[ - 1 ] in [ 'R' , 'r' ] :
m= eval ( money[ 0 : - 1 ] ) * 6
print ( "转换后的美元是{:.2f}美元" . format ( m) )
elif money[ - 1 ] in [ 'M' , 'm' ] :
r= eval ( money[ 0 : - 1 ] ) / 6.00
print ( "转换后的人民币是{:.2f}元" . format ( r) )
else :
print ( "您输入格式有误,请核对" )
请输入您要转换的钱数(R r or M m): 22.33m
转换后的人民币是3.72元
import turtle
turtle. setup( 650 , 350 , 200 , 200 )
turtle. penup( )
turtle. fd( - 250 )
turtle. pendown( )
turtle. pensize( 25 )
turtle. seth( - 40 )
for i in range ( 0 , 4 ) :
if i% 2 == 0 :
turtle. pencolor( "purple" )
turtle. circle( 40 , 80 )
else :
turtle. pencolor( "yellow" )
turtle. circle( - 40 , 80 )
turtle. circle( 50 , 80 / 2 )
turtle. pencolor( "purple" )
turtle. fd( 40 )
turtle. circle( 16 , 180 )
turtle. fd( 40 * 2 / 3 )
import turtle as te
te. setup( 800 , 450 , 200 , 200 )
te. seth( 0 )
te. fd( 200 )
te. seth( - 120 )
te. fd( 200 )
te. seth( 120 )
te. fd( 200 )
te. seth( 60 )
te. fd( 200 )
te. seth( - 60 )
te. fd( 400 )
te. seth( 180 )
te. fd( 400 )
te. seth( 60 )
te. fd( 200 )
te. done( )
import turtle as tt
tt. setup( 800 , 450 , 150 , 150 )
tt. seth( 90 )
tt. fd( 100 )
tt. seth( - 30 )
tt. fd( 300 )
tt. seth( - 150 )
tt. fd( 300 )
tt. seth( 90 )
tt. fd( 200 )
tt. seth( 30 )
tt. fd( 200 )
tt. seth( - 90 )
tt. fd( 300 )
tt. seth( 150 )
tt. fd( 300 )
tt. seth( 30 )
tt. fd( 100 )
tt. done( )
import turtle as tt
tt. setup( 1000 , 800 , 500 , 200 )
for i in range ( 0 , 19 , 1 ) :
tt. seth( 90 )
tt. fd( 400 - 20 * i)
tt. seth( 0 )
tt. fd( 400 - 20 * i)
tt. seth( - 90 )
tt. fd( 390 - 20 * i)
tt. seth( - 180 )
tt. fd( 390 - 20 * i)
tt. done( )