Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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

# 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.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.
Posted
Updated 15-Sep-16 8:24am
v2
Comments
[no name] 15-Sep-16 14:17pm    
We are not here to take your tests for you. Or do your homework. Or give you exam answers. The only way you are going to learn is to crack open your text book, take notes, practice and pay attention in class.

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!
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900