循环(和运算符)[已解决] [英] Loops (and the in operator) [solved]

查看:64
本文介绍了循环(和运算符)[已解决]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是Python和OO的新手。我试图建立一个基于问题的输入答案的简单循环,这样如果你输入错误的答案,你会再次被问到这个问题,但如果正确的话,程序会继续。

例如:

法国的首都是什么?


正确答案 - 转到下一个问题。错误的答案。重复一下这个问题


我以前在基础年前编写的程序中有行号并且会有类似的东西。很容易再次指示程序再次提出问题。



10打印法国的首都是什么?

20获得$ #user输入答案

30如果A $ =巴黎然后转到60

40打印这是错误的答案!再试一次

50goto 10

60下一个问题........


我真的发现很难让我的头围绕没有行号的循环。

谢谢,

蒂姆

Hi,
I''m new to Python and OO in general. I am trying to set up a simple loop based around an inputed answer to a question, so that if you input a wrong answer, you are asked the question again, but if correct, the program moves on.

For example:
What is the capital of France?

Correct answer - move on to next question. Wrong answer. Repeat the question

I used to write in basic years ago in which programs had line numbers and would have went something like this. It was easy to direct the program back again to ask the question again.


10 print "what is the capital of France?"
20 get a$ #user inputs answer
30 If A$ = "Paris" then goto 60
40 print "That is the wrong answer!. Try again"
50goto 10
60 The next question........

I''m really finding it hard to get my head round loops without line numbers.
thanks,
tim

推荐答案

#用户输入答案

30如果A
#user inputs answer
30 If A


=" Paris"然后转到60

40打印这是错误的答案!再试一次

50goto 10

60下一个问题........


我真的发现很难让我的头围绕没有行号的循环。

谢谢,

tim
= "Paris" then goto 60
40 print "That is the wrong answer!. Try again"
50goto 10
60 The next question........

I''m really finding it hard to get my head round loops without line numbers.
thanks,
tim





我是Python和OO的新手。我试图建立一个基于问题的输入答案的简单循环,这样如果你输入错误的答案,你会再次被问到这个问题,但如果正确的话,程序会继续。

例如:

法国的首都是什么?


正确答案 - 转到下一个问题。错误的答案。重复一下这个问题


我以前在基础年前编写的程序中有行号并且会有类似的东西。很容易再次指示程序再次提出问题。



10打印法国的首都是什么?

20获得
Hi,
I''m new to Python and OO in general. I am trying to set up a simple loop based around an inputed answer to a question, so that if you input a wrong answer, you are asked the question again, but if correct, the program moves on.

For example:
What is the capital of France?

Correct answer - move on to next question. Wrong answer. Repeat the question

I used to write in basic years ago in which programs had line numbers and would have went something like this. It was easy to direct the program back again to ask the question again.


10 print "what is the capital of France?"
20 get a


这篇关于循环(和运算符)[已解决]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆