Swe 102 Lab
Swe 102 Lab
Swe 102 Lab
LAB # 01
INTRODUCTION
OBJECTIVE
To become familiar with the Python Programming by using an Integrated Development
Environment
THEORY
Programming
The act of writing computer programs is called computer programming. A computer
program is a sequence of instructions written using a computer programming language
to perform specified tasks by the computer. There are a large number of programming
languages that can be used to write computer programs, for example: Python, C, C++,
Java, PHP, Perl, Ruby etc.
Using an IDE will save a lot of time and effort in writing a program. However, one
should be careful of some of the pitfalls of using an IDE as it may not be ideal for
everyone and might not be suitable in every situation. Some IDEs are very complicated
to use and may consume a lot of resources.
Many IDEs support Python Programming Language. Some of the popular IDEs are
listed below.
Standalone IDEs:
• Microsoft Visual Studio Code
https://code.visualstudio.com/
• Eclipse
https://www.eclipse.org/downloads
• NetBeans
https://netbeans.org/downloads/
• Thonny
https://thonny.org/
• Anaconda
https://www.anaconda.com/distribution/
Online IDEs:
• Ideone
https://ideone.com/
• Online GDB
https://www.onlinegdb.com/online_python_debugger
Step#1: Go to https://thonny.org
Step#2: Download the version for Windows and wait a few seconds while it
downloads.
Step#4: Follow the installation wizard to complete the installation process and just
click "Next".
Step#5: After completing the installation, open Thonny IDE. A window as shown in
the following figure should open.
print("Hello, World! \n Python is fun") instructs the computer to print on the screen the
string of characters enclosed by the quotation marks.
\n is an escape sequence that means newline. It causes the cursor to position to the
beginning of the next line on the screen.
pound sign (#) is a comment on a line, called a line comment, or enclosed between
three consecutive single quotation marks (''') on one or several lines, called a paragraph
comment.
Python programs are case sensitive. It would be wrong, for example, to replace print in
the program with Print. Several special characters can be seen (#, ", ()) in the program.
They are used in almost every program. Table 1.1 summarizes their uses.
Step#1: Go to File > New. Then save the file with .py extension.
Step#3: Then Go to Run > Run current script or simply click F5 to run it
EXERCISE
A. Create a file named lab1.py. Write the following code in the file. Execute it and
show the output. (You can use the Snipping Tool to take a snapshot of your output
window).
1. Code:
# My first program
print("Welcome in the world of programming! \n")
Output:
2. Code:
#My second program
print("Welcome in the ")
print("world of programming! \n")
Output:
B. Write a program in Python language that prints your bio-data on the screen.
Show your program and its output.