Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

Exercises

Command-Line Exercises

  1. Simple Commands. Enter the following one-line commands to Python:

    • copyright
    • license
    • credits
    • help
  2. Simple Expressions. Enter one-line commands to Python to compute the following:

    • 12345 + 23456
    • 98765 - 12345
    • 128 * 256
    • 22 / 7
    • 355 / 113
    • (18-32)*5/9

    • -10*9/5+32

IDLE Exercises

  1. Create an Exercises Directory. Create a directory (or folder) for keeping your various exercise scripts. Be sure it is not in the same directory in which you installed Python.

  2. Use IDLE's Shell Window. Start IDLE. Refer back to the exercises in the section called “Command-Line Interaction”. Run these exercises using IDLE.

  3. Use IDLE's File WindowStart IDLE. Note the version number. Use New Window under the File menu to create a simple file. The file should have the following content.

    """ My First File """
    print __doc__

    Save this file in your exercises directory; be sure the name ends with .py. Run your file with the Run Module menu item in the Run menu, usually F5 .

Script Exercises

  1. Simple Script. Create a Python file with the following three commands, each one on a separate line: copyright, license, credits.

  2. Print Script. Create and run Python file with commands like the following examples: print 12345 + 23456; print 98765 - 12345; print 128 * 256; print 22 / 7.

  3. Another Simple Print Script. Create and run a Python file with commands like the following examples: print "one red", 18.0/38.0; print "two reds in a row",(18.0/38.0)**2.

  4. Numeric Types. Compare the results of 22/7 and 22.0/7. Explain the differences in the output.


 
 
  Published under the terms of the Open Publication License Design by Interspire