小编api*_*hel的帖子

Python:查找并指向字符串的中点

我刚开始学习Python(作为我的第一语言,所以我几乎什么都不知道)并且遇到了这个问题.

找到单词的中点,并使用插入符"^"指向它.

例,

Computer
   ^
Run Code Online (Sandbox Code Playgroud)

感谢任何人可以给我的提示.

python

1
推荐指数
1
解决办法
8252
查看次数

Python如果/ elif与random.randint一起出现问题

这是一个更大的问题的一部分,但我有这个if/elif函数的一些问题.

def fish():
    import random   

    score = 0

    i = random.randint(0,39)

    if i == [0,19]:
        print("You caught nothing!")
    elif i == [20,39]:
        print("You caught a Minnow! +10 points.")
        score += 10
    print(i)
    print(score)
fish()
Run Code Online (Sandbox Code Playgroud)

当我运行这个时,我得到的是randint数字,得分为0.我不确定我在这里做错了什么.

python python-3.x

1
推荐指数
1
解决办法
1066
查看次数

C数学和零结果

不知道这里有什么问题,但我一直得到0的结果.预期的结果是0.2222222.我想我必须为我的一个变量分配零,但我无法弄清楚这是怎么回事.任何帮助,将不胜感激.谢谢

#include <stdio.h>
#include <math.h>

int main()
{
    double vs = 10;
    double rs = 100;
    double rl_start = 50;
    double rl_stop = 150;
    double rl_step = 5;

    double i, j;
    double n = rl_start;
    int count;

    do
    {
        j = ((rl_start) + (rl_step * count));
        i = (pow(vs, 2) * j) / pow((rs + j),2);
        printf("%lf", i);
        count++;

    }while(j <= rl_stop);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
92
查看次数

标签 统计

python ×2

c ×1

python-3.x ×1