不允许使用“任何” Python关键字或内置函数到达总数 [英] Not Allowed to use "any" Python keywords or built in function's to arrive to total

查看:119
本文介绍了不允许使用“任何” Python关键字或内置函数到达总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一个for循环,将值1到end(包括1和12)相加。结束是变量不能使用变量调用''总和''



结束为6,你的代码应打印出结果:

21

即1 + 2 + 3 + 4 + 5 + 6.



不包括raw_input语句或定义变量端。所以在下面的框中写下你的代码,假设已经定义了结尾。



MY CODE ..end变量已经定义,所以不能定义它..



总计= 0

index = 1

for i in index< = end:

索引+ = 1

打印(总计)

Write a for loop that sums the values 1 through end, inclusive. end is a variable cannot Use A Variable Called ''sum''

"end" to be 6, your code should print out the result:
21
which is 1 + 2 + 3 + 4 + 5 + 6.

do not include raw_input statements or define the variable end. so write your code in the following box assuming end is already defined.

MY CODE.. "end" variable is already defined, so cannot define it..

total = 0
index = 1
for i in index <= end:
index += 1
print (total)

推荐答案

问题一:为什么python 2.7?

问题二:请明确你需要用你的代码实现什么



为了得到正确答案你需要提出正确的问题
question one : why python 2.7 ?
question two : please be clear on what you need to achieve with your code

"in order to get right answer u need to ask right question"


这篇关于不允许使用“任何” Python关键字或内置函数到达总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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