我需要快速解决这3个问题吗?我是编码的新手! [英] I need a quick solution of these 3 questions? I am new to coding!

查看:61
本文介绍了我需要快速解决这3个问题吗?我是编码的新手!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Q1。逐步执行以下代码并填写最终值

Q1. Step through the following code and fill in the final values

x = 4
y = 10
z = 'Cat'

if x < 10:
    z = 'Dog'
if y <= 22:
    print(z)
    if x <= 11 and y > 4:
        z = x + y
for x in range(11):
    y += x



#将打印到什么repl? x,y和z的最终值是什么?



2.以惯用语形式重写以下片段




# What would be printed to the repl? What are the final values of x, y, and z?""""""

2. Rewrite the following snippet in an "Idiomatic Python" form

counties = ['Arkansas', 'Ashley', 'Baxter', 'Benton', 'Boone', 'Bradley', 'Calhoun', 'Carroll', 'Chicot', 'Clark']

def group_counties(counties):
    d = {}
    for i in range(len(counties)):
        county = counties[i]
        first_letter = county[0][0]
        if first_letter in d:
            temp = d[first_letter]
            temp.append(county)
            d[first_letter] = temp
        else:
            d[first_letter] = list()
            d[first_letter].append(county)
    print(d)





3.写一个函数,打印0到50之间的数字,除非在下列情况下。如果数字是五个打印的倍数游戏而不是数字。

如果数字是数字的倍数四,不到四十四打印鱼而不是数字。使用您选择的语言。



我尝试过:



我是编码的新手。所以想了解更多。



3.Write a function that prints the numbers from 0 to 50 except in the following cases.If the number is a multiple of five print "Game" instead of the number.
If the number is a multiple of four and less than forty-four print "Fish" instead of the number. Use your language of choice.

What I have tried:

I am new to coding. So want to learn more.

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但是我们不会为你做这一切!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


我们不做你的HomeWork。

HomeWork不会测试你的技能在乞求其他人们做你的工作,它将帮助你的老师检查你对你所学课程的理解,以及你应用它们时遇到的问题。

任何失败都会帮助你的老师发现你的弱点并设定补救措施。

所以,重读你的课程并开始工作。试着找到答案。
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, reread your lessons and start working. Try to find the answers.


这篇关于我需要快速解决这3个问题吗?我是编码的新手!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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