0% found this document useful (0 votes)
5 views10 pages

Week4_CM_MDL_CS328

This document outlines Module 4 of the CS328 course on Python IDLE, focusing on the introduction to the Python 3 IDLE environment and the installation of Pydroid for Android. It covers the features of Python IDLE, including its interactive and development modes, menus, and commands, as well as providing resources for further learning. Additionally, it includes an assessment section and hands-on activity instructions for using Pydroid 3 on mobile devices.

Uploaded by

joeycabopomaam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

Week4_CM_MDL_CS328

This document outlines Module 4 of the CS328 course on Python IDLE, focusing on the introduction to the Python 3 IDLE environment and the installation of Pydroid for Android. It covers the features of Python IDLE, including its interactive and development modes, menus, and commands, as well as providing resources for further learning. Additionally, it includes an assessment section and hands-on activity instructions for using Pydroid 3 on mobile devices.

Uploaded by

joeycabopomaam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

ASIAN INSTITUTE OF COMPUTER STUDIES

Bachelor of Science in Computer Science


Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

MODULE 4: PYTHON IDLE


WEEK 4

Learning Outcomes:
After completing this course you are expected to demonstrate the following:
1. Introduce Python 3 IDLE environment
2. Install Pydroid for android mobile phones.

A. Engage

Figure 4.0 Winston Churchill


Winston Churchill is best remembered for successfully leading Britain through World War II.

B. Explain
IDEs vary greatly in the level and kind of intelligence they provide, which is why so many IDEs exist.
You may find the level of help obtained from one IDE to be insufficient to your needs, but another IDE
hovers over you like a mother hehen.
n. Every developer has different needs and, therefore, different IDE
requirements. The point is to obtain an IDE that helps you write clean, efficient code quickly and
easily.

The best IDEs double as training tools. Given enough features, an IDE can help you explore code
written by true experts. Tracing through applications is a time
time-honored
honored method of learning new skills
and honing the skills you already possess. A seemingly small advance in knowledge can often become
a huge savings in time later. When loo
looking
king for an IDE, don’t just look at debugging features as a means
to remove errors — see them also as a means to learn new things about Python.

C. Explore
Video Title:
Python - A first introduction to the Python IDLE Interface

YouTube Link:
https://www.youtube.com/watch?v=bOvqYw1SZJg

Module Video Filename:


Python - A first introduction to the Python IDLE Interface_WEEK4

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 1 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

D. Elaborate
Python IDLE

IDLE is an integrated development environment (an application like a word processor which helps
developers to write programs) for Python. IDLE is the Python IDE which comes with Python, built with
the tkinter GUI toolkit. It has two modes Interactive and Development.

IDLE features:

 Cross Platform: Works on Unix and Windows.


 Multi-window text editor with syntax highlighting and smart indent and other.
 Python shell window with syntax highlighting.
 Integrated debugger.
 Coded in Python, using the tkinter GUI toolkit

Python IDLE: Interactive Mode

Let us assume that we've already installed Python (here we installed Python 3.2 on a standard pc with
windows 7 OS). Click on start button and find Python 3.2 tab in installed programs.

Figure 4.1

Now clicking on Python 3.2 tab you can see the Python program development tool named IDLE (Python
GUI).

Figure 4.2

To start IDLE click on IDLE (Python GUI) icon, you will see a new window opens up and the cursor is
waiting beside '>>>' sign which is called command prompt.

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 2 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

Figure 4.3

This mode is called interactive mode as you can interact with IDLE directly, you type something (single
unit in a programming language) and press enter key Python will execute it, but you can not execute
your entire program here. At the command prompt type copyright and press enter key Python executes
the copyright information.

Figure 4.4

Now Python is ready to read new command. Let's execute the following commands one by one.

Command -1 : print("Hello World")


Command -2 : primt("Hello World")

The first command is correct and but the second one has a syntax error, here is the response from
Python.

Figure 4.5

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 3 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

Python IDLE Menus

File Menu

 New window: Create a new editing window. Shortcut key : Ctrl+N


 Open : Open an existing file. Shortcut key : Ctrl+O
 Recent Files : List of recently open files.
 Open module : Open an existing module. Shortcut key : Alt+M
 Class browser : Show classes and methods in the current file. shortcut key : Alt+C
 Path browser : Show sys.path directories, modules, classes, and methods.
 Save : Save current window to the associated file. Shortcut key : Ctrl+S
 Save As : Save current window to new file, which becomes the associated file. Shortcut key :
Ctrl+shift+S
 Save Copy As : Save current window to a different file without changing the associated file.
Shortcut key : Alt+shift+S
 Print window. Shortcut key : Ctrl+P
 Close : Close current window (asks to save if unsaved). Shortcut key : Alt+F4
 Exit : Close all windows and quit IDLE (asks to save if unsaved). Shortcut key : Ctrl+Q

Edit Menu.

 Undo : Undo last change to current window (max 1000 changes). Shortcut key : Ctrl+Z
 Redo : Redo last undone change to current window. Shortcut key : Ctrl+shift+Z
 Cut : Copy selection into system-wide clipboard; then delete the selection. Shortcut key : Ctrl+X
 Copy : Copy selection into the system-wide clipboard. Shortcut key : Ctrl+C
 Paste : Insert system-wide clipboard into the window. Shortcut key : Ctrl+V
 Select All: All Select the entire contents of the edit buffer. Shortcut key : Ctrl+A
 Find... : Open a search dialog box with many options. Shortcut key : Ctrl+F
 Find again : Repeat last search. Shortcut key : Ctrl+G
 Find selection : Search for the string in the selection. Shortcut key : Ctrl+F3
 Find in Files... : Open a search dialog box for searching files. Shortcut key : Alt+F3
 Replace...: Open a search-and-replace dialog box. Shortcut key : Ctrl+H
 Go to line : Ask for a line number and show that line. Shortcut key : Alt+G
 Expand word : Expand the word you have typed to match another word in the same buffer;
repeat to get a different expansion
 Show call tip. Shortcut key : Ctrl+backslash
 Show surrounding parentheses. Shortcut key : Ctrl+0
 Show completions. Shortcut key : Ctrl+space

Shell Menu

 View Last Restart. Shortcut key : F6


 Restart shell. Shortcut key : Ctrl+F6

Debug Menu

 Go to file/line look around the insert point for a filename and line number, open the file, and
show the line.
 Debugger
 Stack viewer shows the stack traceback of the last exception
 Auto open stack viewer.
Options Menu
 Configure IDLE

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 4 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

Windows Menu
 Zoom height. Shortcut key : Alt+2
 Python shell.
Help Menu
 About IDLE.
 IDLE Help.
 Python Documents. Shortcut key : F1

Python IDLE : Development mode


At first, start with a new window.

Figure 4.6
Clicking on "New window" under file menu a new window will come. Type print "Hello World"
in the new window.

Figure 4.7
Let's save (Save command is located under the File menu) the file now. We save the program as
helloworld.py under E:/python-programs folder.

Figure 4.8

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 5 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

To run the program select Run menu.

Figure 4.9

Now click on Run Module or press F5 as a shortcut key to see the result.

Figure 4.10

Python IDLE: Syntax and Shell Colors


Syntax Color Shell Color
Keywords Orange Console output Brown
Strings Green Stdout Blue
Comments Red Stderr Dark green
Definitions Blue Stdin Black

Python command line interface


There are some users who prefer command line intersection, rather than a GUI interface. To go
Python command line, click on Python 3.2 tab then click on Python(command line).

Figure 4.11

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 6 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

Here is the screen shot of Python command line interface. To return type exit() or Ctrl+Z plus
Enter key.

Figure 4.12

E. Evaluate
ASSESSMENT:
Instruction: Answer the questionsbelow. Write your answer in the space provided for 2 points
each.
MATCHING TYPE: Match Column A with Column B.

1. Open an existing module. A. Paste


2. Redo last undone change to current window. B. Replace
C. Open module
3. Path Show sys.path directories, modules, classes, D. Go to line
and methods. E. Redo
F. Path browser
4. Find Search for the string in the selection. G. Find
5. Insert system-wide clipboard into the window. H. Class browser
6. Open a search-and-replace dialog box. I. Cut
J. Find selection
7. Copy selection into system-wide clipboard; then
delete the selection.
8. Show classes and methods in the current file.
9. Ask for a line number and show that line.
10. Open a search dialog box with many options.

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 7 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

HANDS-ON ACTIVITY 4.11


Installing
talling Python on Android Phone (Pydroid
Pydroid 3 - IDE for Python 3)

Official PlayStore Link:


 https://play.google.com/store/apps/details?id=ru.iiec.pydroid3&hl=en_US&gl=US

Figure 4.13

Use The Python Shell


The blank page that appears when you open Pydroid 3 is its inbuilt Python shell. Just like the
Python shell on the PC, it sees any command written on it as a Python code by default.
To use the shell, type any Python command and click the big play button at the editor's lower-
left corner. This opens a Python interpreter that displays the output of your code.
However, you can also access the Python shell from the command line. To do that, go to
Terminal by clicking on the three menu icon at the app's top
top-left
left corner. Next, type python and
tap the enter arrow on your soft keyboard to open the command line Python interpreter. Type
exit() to leave the command line Python shell.

Figure 4.14

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 8 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

Save Folders And Files On Your Device


Just like any other code editor, Pydroid 3 has an interface that lets you save your file in any
named folder on your device. If you want to create a project folder, you also get to make new
folders with its file saving options.
To use the folder option, tap the folder sign at the top top-right
ht corner of the editing shell.
Tap Save and select InternalStorage
InternalStorage.. Next, tap on a preferred destination folder and tap SELECT
FOLDER at the top of the screen. On the next menu, enter a preferred file name and click
on SAVE.

Figure 4.15

However, if you like to create a new project folder, repeat the process above, but tap on the NEW
FOLDER option instead of SELECT FOLDER
FOLDER.. Give your new folder a preferred name and tap CREATE to
save the folder. Next, click on the SELECT FOLDER option. Name your new file and
a tap SAVE to save your
new file in the folder you just created.

Note that the newly created file doesn't need a file extension if it's a Python file. But in case you need to
use another language file to serve your project, ensure that you include the fil
file extension that applies to
that language while saving such a file. For instance, a CSS file should be saved as Name.css,
replacing Name with your preferred file name.

Figure 4.16
Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 9 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CS328 - Programming Languages
3rd Year – 2nd Semester

To update the changes you've made to an existing file, tap the folder sign at the top-right corner of the
editor, and select Save.

To create a new file entirely, tap the folder sign. Select New and follow the steps highlighted earlier to
save your file in a folder. If you want your new file to be in the same directory as the existing one,
ensure that you select the same folder that contains the existing one.

References:

1. Python Download and Installation Instructions–

https://www.ics.uci.edu/~pattis/common/handouts/pythoneclipsejava/python.html

2. Python IDLE –

https://www.w3resource.com/python/python-ide.php

3. How To Install and Code Python on Android With Pydroid 3

https://www.makeuseof.com/install-pydroid-android/

Facilitated By:
Name :
MS Teams Account (email) :
Smart Phone Number :

Prepared and Validated By: Mr. Darwin Dela Cruz | Dean Manuel Luis C. Delos Santos, MSCS Page 10 of 10

You might also like