本文介绍了我需要快速解决这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.

推荐答案



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

11-01 02:04