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.