homework-double-check-and-quick-question

Need some double check on a homework question. Also one quick question on finding key in a list of dictionary data structure.

Question1:

Use list comprehension to go through the numbers 0-10 and assign to a new list of only even numbers. You must use the range function in the list comprehension, and the final list must include 0 and 10.

evenlist = [x for x in range(0,10) if x%2 == 0]

print(evenlist)

My result only prints out 0 to 8 How can i include 10 in it?

Question 2:

In the data structure (gene_ds) in the question directly above, how can I print out the ‘Aka’ key for the Gene ALK?

gene_ds =[

{‘Gene’: ‘KRAS’, ‘Expression’: 2.4, ‘Aka’: ‘RALD’},

{‘Gene’: ‘EGFR’, ‘Expression’: 2.9, ‘Aka’: ‘ERBB1’},

{‘Gene’: ‘ALK’, ‘Expression’: 3.5, ‘Aka’: ‘NBLST3’},

]

– What i did is gene_ds[0][‘Aka’]

It’s wrong because i was printing the value.

Question3 :

Add a new entry to the gene_ds data structure that has Gene: BRCA, Expression: 10.0, and ‘Aka’: BRCC1

No idea how to add this. Tried to use .update method but failed

Question4:

Given two sets, a and b. How could I find the union of both a and b, and assign this to a new set c, using a method of the set a.

Answer:

c = a.union(b)

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now