Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
28 views

Python 1

The document discusses using IDLE as an integrated development environment for Python, explaining that IDLE allows writing and running code through its code editor and interactive shell which immediately executes entered code and displays any results. Various list methods and operations in Python like appending, popping, removing, and inserting items are also covered, along with checking if an item is a list and accessing nested lists.

Uploaded by

Sumith 2K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Python 1

The document discusses using IDLE as an integrated development environment for Python, explaining that IDLE allows writing and running code through its code editor and interactive shell which immediately executes entered code and displays any results. Various list methods and operations in Python like appending, popping, removing, and inserting items are also covered, along with checking if an item is a list and accessing nested lists.

Uploaded by

Sumith 2K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Teran Subasinghe

 Goto CMD
 Goto the Installation Directory
 Ex: C:\Python31\
 Type
 Python.exe –V (To check version)
 Python (To execute python)
 IDLE lets you write code in its full-featured code editor
as well as experiment with code at the Python Shell.

 You’ll use the code editor later in this book but, when
learning Python, IDLE’s shell really rocks, because it
lets you try out new Python code as you go.

 When you first start IDLE, you are presented with the
“triple chevron” prompt (>>>) at which you enter
code. The shell takes your code statement and
immediately executes it for you, displaying any results
produced on screen.
Creating Lists
 Len(movies)
◦ Return the Length of List
 movies.append(“Fist of Fury”)
◦ Add another Value to End of the List
 movies.pop()
◦ Delete the last Item from the List
 movies.extend([“Dragon”,”Dear”])
◦ Add another List to an Existing List
 movies.remove(“Dragon”)
◦ Remove a specific data item from a List
 movies.insert(0,“jungle book”)
◦ Add a data item to a specific location of a List

 Python Lists can contain data of Mixed Type

Lists Cont..
The target identifier is like any other name in your code. As your list is
iterated over, the target identifier is assigned each of the data values in your
list, in turn. This means that each time the loop code executes, the target
identifier refers to a different data value.
 An alternative to using for is to code the iteration with a
while loop. Consider these two snippets of Python code,
which perform the same action:
 To Check whether it’s a list
 Isinstance(listName,list) -> Boolean

 To Access a nested List and Print the content


 For each_item in movies :
if isinstance(each_item,list) :
for nested_item in each_item :
print(nested_item)
else :
print(each_item)

You might also like