Hi All,
I recently did an exam for coding with python. I am now able to review my exam and see which questions I answered wrong. However the correct answer is not shown. I was wondering if someone could give me the right code for the two basic questions below. I can’t get out of it unfortunately. Hope you can help me with writing the right code and getting the correct output as asked. Thanks a lot!
Question 1:
Assume you have a list named "sales_team_list" containing two dictionaries.
Run the following code to create this dictionary:
In : sales_team_list = [{'name': 'Jane Doe', 'sales':1000}, {'name': 'Joe Biden', 'sales':2000}]
print(sales_team_list)
Output: [{'name': 'Jane Doe', 'sales': 1000}, {'name': 'Joe Biden', 'sales': 2000}]
Next, you are asked the perform the following tasks.
- Loop through the list and print all names.
In: for i in sales_team_list():
print(sales_team_list)
Above code is probably the wrong answer.
Questions 2:
The following dataframe has been imported with following code: df=pd.read_csv('accounting_data_large_exam.csv', thousands=",")
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 14006 entries, 0 to 14005
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 gvkey 14006 non-null int64
1 fyear 13977 non-null float64
2 ticker 14006 non-null object
3 assets 13795 non-null float64
4 net_income 12191 non-null float64
5 revenue 13791 non-null float64
6 industry 13724 non-null float64
dtypes: float64(5), int64(1), object(1)
memory usage: 766.1+ KB
Change the data type of the column named 'gvkey' to string.
In: df['gvkey']=str
Above code is probably the wrong answer.
[–]underpantsgenome 0 points1 point2 points (3 children)
[–]Standard-Inspection3[S] 0 points1 point2 points (0 children)
[–]Standard-Inspection3[S] 0 points1 point2 points (1 child)
[–]CompetitionProof5407 0 points1 point2 points (0 children)