+ 1
Given a list of birth years calculate how old these people will be in the year 2050 and, output the resulting list.
I m not a pro member so i am unable to open it. but i want to understand these type of code coach problems.can anyone help me to understand this?
8 Antworten
+ 8
It's not possible, you have to take Pro for unlocking all lessons and code-coaches, but if you wanna know these questions you can talk with a pro member. But I think it's not fair.
+ 1
If you wish to understand it, then write your own concept and test the results against values you can manually calculate.
This will give you a much deeper understanding, & teach you how to develop code without relying on others to validate
+ 1
birth_years = [1995, 2004, 2019, 1988, 1977, 1902] #1. All birth years stored in this list
result=list(map(lambda x: 2050-x,birth_years))#2. Ages calculated and stored in this list using map and lambda
print(result) #3. Print the age list
+ 1
def future_age(x):
return 2050 - x
birth_years = [1995, 2004, 2019, 1988, 1977, 1902]
result = list(map(lambda x: 2050 -x, birth_years))
print(result)
+ 1
birth_years = [1995, 2004, 2019, 1988, 1977, 1902]
#your code goes here
b=list(map(lambda x: -x+2050,birth_years))
print(b)
+ 1
birth_years = [1995, 2004, 2019, 1988, 1977, 1902]
#your code goes here
result = list(map(lambda x: 2050-x, birth_years))
print(result)
0
Ill help you understand it.
Stop being cheap and buy the pro membership
- 1
Think this is shortest code:
result = list(map(lambda x: (x-2050)*-1, birth_years))
print(result)
Ask if u have questions!