찾다
백엔드 개발파이썬 튜토리얼用Python做的数学四则运算_算术口算练习程序(后添加减乘除)

最近着迷上了 Python

用Python给小宝做的数学算数口算练习程序(2015年1月添加四则运算)!

给小宝做的口算游戏:

#用Python给小宝做的数学算数口算练习程序(2015年1月添加四则运算)!
#给小宝做的口算游戏:


import string
 import random
 input=11
 nums=10
 num=0
 righ1t=0 #分数#
flagwrong=0 #没错过
print e[1;34mThis text is bold blue.e[0m
 print 一共有%d道题目:%(nums)
 print e[33;45;1mBold yellow on magenta.e[0m ;
 while True:
 flagwrong=0
 if num>=nums:
 print 一共(1次就)做对了%d道/%d道 题目%(righ1t,nums),
 if righ1t>=10:
 print 你真棒啊! 100分啊!!!
elif righ1t>=8:
 print 你不错啊,80分以上啊!!!
else:
 print 还要加油哦!
break;
 elif num num=num+1

 x=random.randint(1, 100) #100以内的数字
y=random.randint(1, 10)
 print


 symbol=random.randint(0,3)
 #symbol=3 #测试除法#
if 0==symbol: #加法
# 内循环-做题
print 第%d题:%d+%d=%(num,x,y),
 input=raw_input()
 intp=string.atoi(input)
 print intp
 while intp!=(x+y):
 print 不对! %d+%d不等于%d%(x,y,intp)
 flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
print 再算一遍,第%d题:%d+%d=%(num,x,y),
 input=raw_input()
 intp=string.atoi(input)
 if intp==x+y:
 break;
 continue;
 if intp == (x+y):
 print 对了! %d+%d就是等于%d%(x,y,intp)
 if flagwrong==0:
 righ1t=righ1t+1
 continue;
 break;


 elif 1==symbol: #减法
# 内循环-做题
if x print 第%d题:%d-%d=%(num,x,y),
 input=raw_input()
 intp=string.atoi(input)
 print intp
 while intp!=(x-y):
 print 不对! %d-%d不等于%d%(x,y,intp)
 flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
print 再算一遍,第%d题:%d-%d=%(num,x,y),
 input=raw_input()
 intp=string.atoi(input)
 if intp==x-y:
 break;
 continue;
 if intp == (x-y):
 print 对了! %d-%d就是等于%d%(x,y,intp)
 if flagwrong==0:
 righ1t=righ1t+1
 continue;
 break;


 elif 2==symbol: #乘法
# 内循环-做题
#if x print 第%d题:%d*%d=%(num,x,y),
 input=raw_input()
 intp=string.atoi(input)
 print intp
 while intp!=(x*y):
 print 不对! %d*%d不等于%d%(x,y,intp)
 flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
print 再算一遍,第%d题:%d*%d=%(num,x,y),
 input=raw_input()
 intp=string.atoi(input)
 if intp==x*y:
 break;
 continue;
 if intp == (x*y):
 print 对了! %d*%d就是等于%d%(x,y,intp)
 if flagwrong==0:
 righ1t=righ1t+1
 continue;
 break;


 elif 3==symbol: #除法
# 内循环-做题
if x print 第%d题:%d/%d=%(num,x,y),
 print 商?:,

input=raw_input()
 intp=string.atoi(input)
 print 余数是?:,
input2yushu=raw_input()
 intp2yushu=string.atoi(input2yushu)


 print 商:,
print intp,
 print 余数是:,
print intp2yushu

 while x !=( ( intp * y)+intp2yushu ):
 print 不对! %d/%d不等于商%d,余%d !%(x,y,intp,intp2yushu)
 flagwrong=1; #错过一次,就不能做成绩(分数)的增长了
print 再算一遍,第%d题:%d/%d的商=?%(num,x,y),
 input=raw_input()
 intp=string.atoi(input)
 print 余?=,
input2yushu=raw_input()
 intp2yushu=string.atoi(input2yushu)

 if x ==( intp*y + intp2yushu ):
 break;
 continue;
 if x == ( (intp*y)+intp2yushu ):
 print 对了! %d/%d就是等于商%d,余%d !%(x,y,intp,intp2yushu)
 if flagwrong==0:
 righ1t=righ1t+1
 continue;
 break;


 #100以内的 加法/减法/乘法/除法

num=0

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
Python의 하이브리드 접근법 : 컴파일 및 해석 결합Python의 하이브리드 접근법 : 컴파일 및 해석 결합May 08, 2025 am 12:16 AM

PythonuseSahybrideactroach, combingingcompytobytecodeandingretation.1) codeiscompiledToplatform-IndependentBecode.2) bytecodeistredbythepythonvirtonmachine, enterancingefficiency andportability.

Python 's 'for'와 'whind'루프의 차이점을 배우십시오Python 's 'for'와 'whind'루프의 차이점을 배우십시오May 08, 2025 am 12:11 AM

"for"and "while"loopsare : 1) "에 대한"loopsareIdealforitertatingOverSorkNowniterations, whide2) "weekepindiTeRations.Un

Python Concatenate는 중복과 함께 목록입니다Python Concatenate는 중복과 함께 목록입니다May 08, 2025 am 12:09 AM

Python에서는 다양한 방법을 통해 목록을 연결하고 중복 요소를 관리 할 수 ​​있습니다. 1) 연산자를 사용하거나 ()을 사용하여 모든 중복 요소를 유지합니다. 2) 세트로 변환 한 다음 모든 중복 요소를 제거하기 위해 목록으로 돌아가지 만 원래 순서는 손실됩니다. 3) 루프 또는 목록 이해를 사용하여 세트를 결합하여 중복 요소를 제거하고 원래 순서를 유지하십시오.

파이썬 목록 연결 성능 ​​: 속도 비교파이썬 목록 연결 성능 ​​: 속도 비교May 08, 2025 am 12:09 AM

fastestestestedforListCancatenationInpythondSpendsonListsize : 1) Forsmalllist, OperatoriseFficient.2) ForlargerLists, list.extend () OrlistComprehensionIsfaster, withextend () morememory-efficientBymodingListsin-splace.

Python 목록에 요소를 어떻게 삽입합니까?Python 목록에 요소를 어떻게 삽입합니까?May 08, 2025 am 12:07 AM

toInsertElmentsIntoapyThonList, useAppend () toaddtotheend, insert () foraspecificposition, andextend () andextend () formultipleElements.1) useappend () foraddingsingleitemstotheend.2) useinsert () toaddatespecificindex, 그러나)

Python은 후드 아래에 동적 배열 또는 링크 된 목록이 있습니까?Python은 후드 아래에 동적 배열 또는 링크 된 목록이 있습니까?May 07, 2025 am 12:16 AM

pythonlistsareimplementedesdynamicarrays, notlinkedlists.1) thearestoredIntIguousUousUousUousUousUousUousUousUousUousInSeripendExeDaccess, LeadingSpyTHOCESS, ImpactingEperformance

파이썬 목록에서 요소를 어떻게 제거합니까?파이썬 목록에서 요소를 어떻게 제거합니까?May 07, 2025 am 12:15 AM

PythonoffersfourmainmethodstoremoveElementsfromalist : 1) 제거 (값) 제거 (값) removesthefirstoccurrencefavalue, 2) pop (index) 제거 elementatAspecifiedIndex, 3) delstatemeveselementsByindexorSlice, 4) RemovesAllestemsfromTheChmetho

스크립트를 실행하려고 할 때 '허가 거부'오류가 발생하면 무엇을 확인해야합니까?스크립트를 실행하려고 할 때 '허가 거부'오류가 발생하면 무엇을 확인해야합니까?May 07, 2025 am 12:12 AM

Toresolvea "permissionDenied"오류가 발생할 때 오류가 발생합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

mPDF

mPDF

mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

VSCode Windows 64비트 다운로드

VSCode Windows 64비트 다운로드

Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.