SlideShare a Scribd company logo
1 of 1
Download to read offline
Python question...
Complete without importing any modules. Ie. Don't import csv
Sample CSV:
file.csv containing:
first, last, age, height, weight, gender, lives
Jake, Cace, 24, 64,165, male, Spain
Jenny, Matte, 21, 58, 110, female, Italy
Solution
def csv():
print("CSV Data analysis")
print()
fname = "file.csv" #inputing file name
#Reading the input file into a list with each row as a string
with open(fname) as f:
input_data = f.read().splitlines()
#initialising data
data = []
#iterating through the list containing input data and storing each row as a list of floats.
print (input_data)
for i in range(1, len(input_data)):
row_data = [x for x in input_data[i].split(',')]
data.append(row_data)
return data
print(csv())

More Related Content

More from fasttrackcomputersol

The virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdfThe virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdf
fasttrackcomputersol
 
Identify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdfIdentify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdf
fasttrackcomputersol
 
Please read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdfPlease read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdf
fasttrackcomputersol
 
Perform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdfPerform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdf
fasttrackcomputersol
 
Hospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdfHospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdf
fasttrackcomputersol
 
Finish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdfFinish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdf
fasttrackcomputersol
 
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdfExplain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
fasttrackcomputersol
 
Essay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdfEssay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdf
fasttrackcomputersol
 
Denise and Christy have the same preferences and incomes.pdf
Denise and Christy have the same preferences and incomes.pdfDenise and Christy have the same preferences and incomes.pdf
Denise and Christy have the same preferences and incomes.pdf
fasttrackcomputersol
 
1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf
1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf
1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf
fasttrackcomputersol
 

More from fasttrackcomputersol (17)

The virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdfThe virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdf
 
Step by step procedures how layout is created and used for transistor.pdf
Step by step procedures how layout is created and used for transistor.pdfStep by step procedures how layout is created and used for transistor.pdf
Step by step procedures how layout is created and used for transistor.pdf
 
Show all work. I need to know exactly how you got what you got so I .pdf
Show all work. I need to know exactly how you got what you got so I .pdfShow all work. I need to know exactly how you got what you got so I .pdf
Show all work. I need to know exactly how you got what you got so I .pdf
 
Identify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdfIdentify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdf
 
Q6. Proteins are used for structural integrity inside and outside of.pdf
Q6. Proteins are used for structural integrity inside and outside of.pdfQ6. Proteins are used for structural integrity inside and outside of.pdf
Q6. Proteins are used for structural integrity inside and outside of.pdf
 
Please read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdfPlease read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdf
 
Perform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdfPerform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdf
 
Hospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdfHospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdf
 
Finish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdfFinish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdf
 
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdfExplain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
 
Essay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdfEssay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdf
 
Describe the excel equation that you can use to measure the volumes l.pdf
Describe the excel equation that you can use to measure the volumes l.pdfDescribe the excel equation that you can use to measure the volumes l.pdf
Describe the excel equation that you can use to measure the volumes l.pdf
 
Denise and Christy have the same preferences and incomes.pdf
Denise and Christy have the same preferences and incomes.pdfDenise and Christy have the same preferences and incomes.pdf
Denise and Christy have the same preferences and incomes.pdf
 
Can you create a simple polymorphic program using C++Solution.pdf
Can you create a simple polymorphic program using C++Solution.pdfCan you create a simple polymorphic program using C++Solution.pdf
Can you create a simple polymorphic program using C++Solution.pdf
 
1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf
1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf
1) What are the benefits of DOAS2) What is reheat Why is it requ.pdf
 
Beadline 20t6 October In 1. Briefly describe the homogenco.pdf
Beadline 20t6 October In 1. Briefly describe the homogenco.pdfBeadline 20t6 October In 1. Briefly describe the homogenco.pdf
Beadline 20t6 October In 1. Briefly describe the homogenco.pdf
 
A patient has breast cancer which has metastasized to their lungs. T.pdf
A patient has breast cancer which has metastasized to their lungs. T.pdfA patient has breast cancer which has metastasized to their lungs. T.pdf
A patient has breast cancer which has metastasized to their lungs. T.pdf
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 

Python question...Complete without importing any modules. Ie. Don.pdf

  • 1. Python question... Complete without importing any modules. Ie. Don't import csv Sample CSV: file.csv containing: first, last, age, height, weight, gender, lives Jake, Cace, 24, 64,165, male, Spain Jenny, Matte, 21, 58, 110, female, Italy Solution def csv(): print("CSV Data analysis") print() fname = "file.csv" #inputing file name #Reading the input file into a list with each row as a string with open(fname) as f: input_data = f.read().splitlines() #initialising data data = [] #iterating through the list containing input data and storing each row as a list of floats. print (input_data) for i in range(1, len(input_data)): row_data = [x for x in input_data[i].split(',')] data.append(row_data) return data print(csv())