Difference between revisions of "Introduction to Python"
(27 intermediate revisions by 6 users not shown) | |||
Line 2: | Line 2: | ||
|Chapter_TOC=[[Introduction to Python]] | |Chapter_TOC=[[Introduction to Python]] | ||
|Previous=[[Roomba]] | |Previous=[[Roomba]] | ||
− | |Introduction=Python programming language was created by Guido Van Rossumin in the 1980's. | + | |Introduction=The Python programming language was created by Guido Van Rossumin in the 1980's. |
− | It is a general purpose, object-oriented, expandable and described programming language. Python has an artistic syntax that allows its users to read | + | It is a general purpose, object-oriented, expandable and described programming language. Python has an artistic syntax that allows its users to read and understand the code very easily. |
− | It is used for creation of web applications. | + | It is used for the creation of web applications. It comes with an in-built development environment called IDLE and a large library that supports huge projects. |
− | In this lab, you will | + | In this lab, you will learn how to program in this very exciting language. Furthermore, we will translate some Java programs you may have seen in [[Program_a_day|Program-A-Day]] into Python. Hope you enjoy this lab. |
− | + | ||
− | + | [[Image:Intro_to_Python.png|900px|Image by Graeme Peters]] | |
|Body= | |Body= | ||
− | =Getting Started= | + | ==Installing Python== |
+ | The following steps are used to install python | ||
+ | * Log on to http://www.python.org/download | ||
+ | * Choose the appropriate version for your operating system | ||
+ | |||
+ | |||
+ | ==Running Python programs== | ||
+ | Use the following steps to run all you Python programs. | ||
+ | * Type all Python programs in the IDLE environment | ||
+ | * On the Run tab, click on Run Module or press F5 | ||
+ | [[Image:IDLEImage.jpg|300px|caption]] | ||
+ | |||
+ | |||
+ | ==Getting Started== | ||
===[[HelloWorld]]=== | ===[[HelloWorld]]=== | ||
− | =Primitive Data Types= | + | |
+ | ==Primitive Data Types== | ||
===[[Area Calculation]]=== | ===[[Area Calculation]]=== | ||
===[[Wind Chill]]=== | ===[[Wind Chill]]=== | ||
− | =If/else/elif= | + | |
+ | ==If/else/elif== | ||
===[[Calculate days in a month]]=== | ===[[Calculate days in a month]]=== | ||
===[[Grade Conversion]]=== | ===[[Grade Conversion]]=== | ||
− | =While and for loops= | + | |
− | ===[[ | + | ==While and for loops== |
− | =Conclusion= | + | ===[[ How to use while & for loops]]=== |
+ | |||
+ | ==Exercise:== | ||
+ | Now that you are familiar with the basic concepts of Python. Please, complete the following exercise. | ||
+ | * Choose one of the problems in [[Program_a_day|Program-A-Day]] in the categories '''Primitive Data Types''' or '''If/else/elseif''' or '''While and for loops'''. Translate the solution to your chosen program into its Python equivalent. | ||
+ | |||
+ | ==Conclusion== | ||
+ | In this lab, you were introduced to Python programming language. We also translated solutions of some [[Program_a_day|Program-A-Day]] problems which were written in Java programming language into solutions in Python programming language. Additionally, we talked about primitive data types, if,elif,else conditional statements and loop control structures in Python. In the next lab, you will be introduced to more fun and interesting things about Python programming language. | ||
}} | }} |
Latest revision as of 19:30, 5 April 2012
COMP 1010 Home > Back to Extra Labs
IntroductionThe Python programming language was created by Guido Van Rossumin in the 1980's. It is a general purpose, object-oriented, expandable and described programming language. Python has an artistic syntax that allows its users to read and understand the code very easily. It is used for the creation of web applications. It comes with an in-built development environment called IDLE and a large library that supports huge projects. In this lab, you will learn how to program in this very exciting language. Furthermore, we will translate some Java programs you may have seen in Program-A-Day into Python. Hope you enjoy this lab. |
Contents |
---|
Installing Python
The following steps are used to install python
- Log on to http://www.python.org/download
- Choose the appropriate version for your operating system
Running Python programs
Use the following steps to run all you Python programs.
- Type all Python programs in the IDLE environment
- On the Run tab, click on Run Module or press F5
Getting Started
HelloWorld
Primitive Data Types
Area Calculation
Wind Chill
If/else/elif
Calculate days in a month
Grade Conversion
While and for loops
How to use while & for loops
Exercise:
Now that you are familiar with the basic concepts of Python. Please, complete the following exercise.
- Choose one of the problems in Program-A-Day in the categories Primitive Data Types or If/else/elseif or While and for loops. Translate the solution to your chosen program into its Python equivalent.
Conclusion
In this lab, you were introduced to Python programming language. We also translated solutions of some Program-A-Day problems which were written in Java programming language into solutions in Python programming language. Additionally, we talked about primitive data types, if,elif,else conditional statements and loop control structures in Python. In the next lab, you will be introduced to more fun and interesting things about Python programming language.