資源簡介 成都市8年級信息技術考試Python操作題匯總1、編碼:a = int(input('請輸入第一個加數:'))b = int(input('請輸入第二個加數:'))print(a+b)2、答案:if else3、編碼:passwd='321123'a = input('請輸入密碼:')if a == passwd:print('密碼正確!')else:print('密碼錯誤!')4、編碼:name=input('請輸入您的姓名: ')print(name+',您好!')5、畫正方形(1):import turtle as TT.seth(45)for i in range(4):T.fd(100)T.lt(90)(2)from turtle import * #導入screensize(400,400)pensize(5) #畫筆大小為5pencolor("red") #畫筆顏色為紅fillcolor("green") #填充顏色為綠begin_fill() #開始填充forward(200) #前進200left(90) #左轉90度forward(200) #前進200left(90) #左轉90度forward(200) #前進200left(90) #左轉90度forward(200) #前進200left(90) #左轉90度end_fill() #結束填充done()六邊形from turtle import * #導入pensize(5) #畫筆大小為5pencolor("red") #畫筆顏色為紅fillcolor("green") #填充顏色為綠begin_fill() #開始填充for i in range(6): #循環四次forward(100) #前進200left(60) #左轉90度end_fill() #結束填充7、畫圓編碼:import turtle as t #導入t.color('red') #畫筆顏色為紅t.circle(80) #設置圓直徑t.done()畫弧from turtle import *pensize(4)circle(60, 160)8、請編寫程序,在屏幕上打印出 20 個字母“Q”。答案:print("Q" * 20)9、成績合格:a = int(input('請輸入你的考試成績: '))if a >= 60 :print('成績合格!')else:print('成績不合格!')10、求平均分;a = int(input('請輸入第一次測試成績 '))b = int(input('請輸入第二次測試成績 '))c = (a+b)/2print('兩次平均成績是',c)11、買水果a = input("桃、杏、梨,你想買哪個: ")if a == '桃':print('桃子2元一斤!')elif a == '杏':print('杏子8元一斤!')elif a == '梨':print('梨子6元一斤!')else :print('您的輸入不正確。')12、打星星a = int(input("請輸入你想打印幾層星星: "))for i in range( a+1 ):print('*' * i)13、性別a = input("請輸入你的性別: ")if a != '男' :print('你是女生! ')else:print('你是男生! ')或者:a = input("請輸入你的性別: ")if a == '男' :print('你是男生! ')else :print('你是女生! ')14、你好name = input ("請輸入你的名字: ")print(name + "你好!")15、求正方形面積a=int( input ("請輸入正方形邊長: "))print("正方形的面積為 ",a*a )16、喜歡Pythona = input("你喜歡Python編程語言嗎: ")if a == '喜歡' :print('Python也喜歡你! ')else :print('Python受到十萬點傷害! ')17、畫三角形import turtleturtle.color('blue','red')turtle.pensize(6)turtle.begin_fill()for i in range(3):turtle. forward(100)turtle. left(120)turtle.end_fill()18、畫線import turtleturtle. pensize (4) #設置線條粗細turtle.pencolor('blue') #設為藍色turtle.forward(100) #向右畫條線turtle. left (90) #左轉90度turtle.pencolor('red') #重設為紅色turtle.forward(100) #再畫一條線或者:import turtleturtle. pensize (4) #粗細設為6像素turtle.forward(120) #向右畫條線turtle. left (90) #左轉90度turtle.forward(120) #再畫一條線 展開更多...... 收起↑ 資源預覽 縮略圖、資源來源于二一教育資源庫