PYTHON ASSIGNMENT 10 - LIST COMPREHENSION





Write a list comprehension that prints a list of the cubes of the numbers 1 through 10.

Write a list comprehension that prints out the possible results of two coin flips (example -  one result would be ’ht’)

Write a function that takes in a string and uses a list comprehension to return all the vowels in the string.

Run this list comprehension in your prompt:
[x+y for x in [10, 20, 30] for y in [1, 2, 3]]

Write a function that takes in a list of elements of different types and uses a list comprehension to return all the elements of the list of type int. (Note: Use the python isinstance function)

Write a list comprehension which solves the equation y = x2+1. The solution should print out a list of [x, y] pairs; use the domain x ∈ [−5, 5] and the range y ∈ [0, 10].

Write a list comprehension that finds the integer solutions [x, y] for a circle of radius 5.

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu