SlideShare a Scribd company logo
1 of 1
Download to read offline
1) Write a python code that initializes a list called Numbers with zero elements. 2) Write a while
loop that uses the append list method to update this list so that it has the natural numbers 1,2,3,,
10 as its elements. Print out the list Number using the print statement. 3) Next initialize a list called
Evens with zero elements. This is intended to be a list of boolean elements such that if k is an
index Evens [k]= True if Numbers [k]= even Evens [k]= False if Numbers [k]= odd 3) Using the if-
else construct along with a while loop generate and update the list Evens. Print out the list Evens
4) Extra credit (5 points). Can you use list comprehension to generate the Evens list instead of an
if-else embedded inside a while loop. See how elegant Python can be where a snippet of code
many lines long can be condensed to one line if the correct commands are known to you!

More Related Content

Similar to 1 Write a python code that initializes a list called Number.pdf

Similar to 1 Write a python code that initializes a list called Number.pdf (20)

Python lists
Python listsPython lists
Python lists
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
arrays-120712074248-phpapp01
arrays-120712074248-phpapp01arrays-120712074248-phpapp01
arrays-120712074248-phpapp01
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Sequences: Strings, Lists, and Files
Sequences: Strings, Lists, and FilesSequences: Strings, Lists, and Files
Sequences: Strings, Lists, and Files
 
Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptx
 
11 Unit 1 Chapter 03 Data Handling
11   Unit 1 Chapter 03 Data Handling11   Unit 1 Chapter 03 Data Handling
11 Unit 1 Chapter 03 Data Handling
 
Chapter 10 data handling
Chapter 10 data handlingChapter 10 data handling
Chapter 10 data handling
 
Tuples-and-Dictionaries.pptx
Tuples-and-Dictionaries.pptxTuples-and-Dictionaries.pptx
Tuples-and-Dictionaries.pptx
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
1. python programming
1. python programming1. python programming
1. python programming
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
python
pythonpython
python
 
Python workshop
Python workshopPython workshop
Python workshop
 
ETinCT.pptx
ETinCT.pptxETinCT.pptx
ETinCT.pptx
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Parts of python programming language
Parts of python programming languageParts of python programming language
Parts of python programming language
 
Chapter05
Chapter05Chapter05
Chapter05
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
 

More from abhishek483040

1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdfabhishek483040
 
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdfabhishek483040
 
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
1 Yava iddet kavramn Shannon OLearn Climate science and.pdfabhishek483040
 
1 Write briefly about the difference between feature select.pdf
1 Write briefly about the difference between feature select.pdf1 Write briefly about the difference between feature select.pdf
1 Write briefly about the difference between feature select.pdfabhishek483040
 
1 Write the hypothesis being addressed by the data displaye.pdf
1 Write the hypothesis being addressed by the data displaye.pdf1 Write the hypothesis being addressed by the data displaye.pdf
1 Write the hypothesis being addressed by the data displaye.pdfabhishek483040
 
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdfabhishek483040
 
1 Why is cell division important for both single cellular a.pdf
1 Why is cell division important for both single cellular a.pdf1 Why is cell division important for both single cellular a.pdf
1 Why is cell division important for both single cellular a.pdfabhishek483040
 
1 Write a program that creates an Integer class Date which .pdf
1 Write a program that creates an Integer class Date which .pdf1 Write a program that creates an Integer class Date which .pdf
1 Write a program that creates an Integer class Date which .pdfabhishek483040
 
1 Write a function named time that has an integer parame.pdf
1 Write a function named time  that has an integer parame.pdf1 Write a function named time  that has an integer parame.pdf
1 Write a function named time that has an integer parame.pdfabhishek483040
 
1 Write a paper on the topic The impact of the implementat.pdf
1 Write a paper on the topic The impact of the implementat.pdf1 Write a paper on the topic The impact of the implementat.pdf
1 Write a paper on the topic The impact of the implementat.pdfabhishek483040
 
1 Write a function to add the integers from a to b a and b.pdf
1 Write a function to add the integers from a to b a and b.pdf1 Write a function to add the integers from a to b a and b.pdf
1 Write a function to add the integers from a to b a and b.pdfabhishek483040
 
1 Write a detailed comprehensive brand strategy report for .pdf
1 Write a detailed comprehensive brand strategy report for .pdf1 Write a detailed comprehensive brand strategy report for .pdf
1 Write a detailed comprehensive brand strategy report for .pdfabhishek483040
 
1 Within this assignment you must detail specific material .pdf
1 Within this assignment you must detail specific material .pdf1 Within this assignment you must detail specific material .pdf
1 Within this assignment you must detail specific material .pdfabhishek483040
 
1 Why would you want to make your work reproducible 2 W.pdf
1 Why would you want to make your work reproducible 2 W.pdf1 Why would you want to make your work reproducible 2 W.pdf
1 Why would you want to make your work reproducible 2 W.pdfabhishek483040
 
1 Which of the following statements is not TRUE regarding S.pdf
1 Which of the following statements is not TRUE regarding S.pdf1 Which of the following statements is not TRUE regarding S.pdf
1 Which of the following statements is not TRUE regarding S.pdfabhishek483040
 
1 Winterville a city of population 125000 in the Rust Bel.pdf
1 Winterville a city of population 125000 in the Rust Bel.pdf1 Winterville a city of population 125000 in the Rust Bel.pdf
1 Winterville a city of population 125000 in the Rust Bel.pdfabhishek483040
 
1 Why is transportation considered so important to the US.pdf
1 Why is transportation considered so important to the US.pdf1 Why is transportation considered so important to the US.pdf
1 Why is transportation considered so important to the US.pdfabhishek483040
 
1 Why do cells need their DNA to be condensed before dividi.pdf
1 Why do cells need their DNA to be condensed before dividi.pdf1 Why do cells need their DNA to be condensed before dividi.pdf
1 Why do cells need their DNA to be condensed before dividi.pdfabhishek483040
 
1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdf1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdfabhishek483040
 
1 Why do you think that there are two different types of DN.pdf
1 Why do you think that there are two different types of DN.pdf1 Why do you think that there are two different types of DN.pdf
1 Why do you think that there are two different types of DN.pdfabhishek483040
 

More from abhishek483040 (20)

1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
 
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
 
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
 
1 Write briefly about the difference between feature select.pdf
1 Write briefly about the difference between feature select.pdf1 Write briefly about the difference between feature select.pdf
1 Write briefly about the difference between feature select.pdf
 
1 Write the hypothesis being addressed by the data displaye.pdf
1 Write the hypothesis being addressed by the data displaye.pdf1 Write the hypothesis being addressed by the data displaye.pdf
1 Write the hypothesis being addressed by the data displaye.pdf
 
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
 
1 Why is cell division important for both single cellular a.pdf
1 Why is cell division important for both single cellular a.pdf1 Why is cell division important for both single cellular a.pdf
1 Why is cell division important for both single cellular a.pdf
 
1 Write a program that creates an Integer class Date which .pdf
1 Write a program that creates an Integer class Date which .pdf1 Write a program that creates an Integer class Date which .pdf
1 Write a program that creates an Integer class Date which .pdf
 
1 Write a function named time that has an integer parame.pdf
1 Write a function named time  that has an integer parame.pdf1 Write a function named time  that has an integer parame.pdf
1 Write a function named time that has an integer parame.pdf
 
1 Write a paper on the topic The impact of the implementat.pdf
1 Write a paper on the topic The impact of the implementat.pdf1 Write a paper on the topic The impact of the implementat.pdf
1 Write a paper on the topic The impact of the implementat.pdf
 
1 Write a function to add the integers from a to b a and b.pdf
1 Write a function to add the integers from a to b a and b.pdf1 Write a function to add the integers from a to b a and b.pdf
1 Write a function to add the integers from a to b a and b.pdf
 
1 Write a detailed comprehensive brand strategy report for .pdf
1 Write a detailed comprehensive brand strategy report for .pdf1 Write a detailed comprehensive brand strategy report for .pdf
1 Write a detailed comprehensive brand strategy report for .pdf
 
1 Within this assignment you must detail specific material .pdf
1 Within this assignment you must detail specific material .pdf1 Within this assignment you must detail specific material .pdf
1 Within this assignment you must detail specific material .pdf
 
1 Why would you want to make your work reproducible 2 W.pdf
1 Why would you want to make your work reproducible 2 W.pdf1 Why would you want to make your work reproducible 2 W.pdf
1 Why would you want to make your work reproducible 2 W.pdf
 
1 Which of the following statements is not TRUE regarding S.pdf
1 Which of the following statements is not TRUE regarding S.pdf1 Which of the following statements is not TRUE regarding S.pdf
1 Which of the following statements is not TRUE regarding S.pdf
 
1 Winterville a city of population 125000 in the Rust Bel.pdf
1 Winterville a city of population 125000 in the Rust Bel.pdf1 Winterville a city of population 125000 in the Rust Bel.pdf
1 Winterville a city of population 125000 in the Rust Bel.pdf
 
1 Why is transportation considered so important to the US.pdf
1 Why is transportation considered so important to the US.pdf1 Why is transportation considered so important to the US.pdf
1 Why is transportation considered so important to the US.pdf
 
1 Why do cells need their DNA to be condensed before dividi.pdf
1 Why do cells need their DNA to be condensed before dividi.pdf1 Why do cells need their DNA to be condensed before dividi.pdf
1 Why do cells need their DNA to be condensed before dividi.pdf
 
1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdf1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdf
 
1 Why do you think that there are two different types of DN.pdf
1 Why do you think that there are two different types of DN.pdf1 Why do you think that there are two different types of DN.pdf
1 Why do you think that there are two different types of DN.pdf
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 

1 Write a python code that initializes a list called Number.pdf

  • 1. 1) Write a python code that initializes a list called Numbers with zero elements. 2) Write a while loop that uses the append list method to update this list so that it has the natural numbers 1,2,3,, 10 as its elements. Print out the list Number using the print statement. 3) Next initialize a list called Evens with zero elements. This is intended to be a list of boolean elements such that if k is an index Evens [k]= True if Numbers [k]= even Evens [k]= False if Numbers [k]= odd 3) Using the if- else construct along with a while loop generate and update the list Evens. Print out the list Evens 4) Extra credit (5 points). Can you use list comprehension to generate the Evens list instead of an if-else embedded inside a while loop. See how elegant Python can be where a snippet of code many lines long can be condensed to one line if the correct commands are known to you!