Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Python Language Programming Lab

Rating
-
Sold
-
Pages
5
Uploaded on
03-03-2023
Written in
2022/2023

Python Language Programming Lab

Institution
Course

Content preview

Python Language Programming Lab
Laboratory Notes (1)

Topic:
1. To write a python program that takes in command line arguments as input
and print the number of arguments




Objective:
To write a python program that takes in command line arguments as input and print the
number of arguments.
Description:
Steps to save and run python programs:
1. Open a text editor
2. Type the instructions
3. Save the python script in a file with filename having extension .py
4. To execute the python script, Run the interpreter with the command prompt
python progam_name.py
Print statement: An instruction that causes the Python interpreter to display a value on
the screen.
Ex: Type the following instruction
python
>>> print 4
Displays 4 as output
Input Statement: An instruction used to get input from the user.
Ex: # Get numbers from user
n1 = input('Please enter first number= ')
n2= input('Please enter second number= ')
n3= input('Please enter third number= ')
# sum of three numbers

, total= float(n1) + float(n2)+ float(n3)
print('The sum of three numbers =', total)
Data Types in Python numeric, string, Boolean, list, tuple and dictionary
Numeric: Integers, floating point numbers and complex numbers falls under Python
numbers category. They are defined as int, float and complex class in Python.
Integers can be of any length, it is only limited by the memory available. A floating point
number is accurate up to 15 decimal places. Integer and floating points are separated by
decimal points. 1 is integer, 1.0 is floating point number. Complex numbers are written in
the form, x + yj, where x is the real part and y is the imaginary part.
String is sequence of Unicode characters. We can use single quotes or double quotes to
represent strings. Multi-line strings can be denoted using triple quotes, ''' or """.
Ex: s = 'Hello world!'
# s[4] = 'o'
print("s[4] = ", s[4])


Boolean: Returns True or False
Ex: print(a==b)
Output: True
List: It is an ordered sequence of items. It is one of the most used datatype in Python and is
very flexible. All the items in a list do not need to be of the same type. We can use the slicing
operator [ ] to extract an item or a range of items from a list. Index starts form 0 in Python.
Ex: a=[1,2.2,’python’]
a=[1,2,3,4]
a[2]=10
a
Output:[1,2,10,4]
Tuple: is an ordered sequence of items same as list. The only difference is that tuples are
immutable. Tuples once created cannot be modified. Tuples are used to write-protect data
and are usually faster than list as it cannot change dynamically. It is defined within
parentheses () where items are separated by commas.
Ex: t = (5,'program', 1+3j)

Written for

Institution
Course

Document information

Uploaded on
March 3, 2023
Number of pages
5
Written in
2022/2023
Type
Class notes
Professor(s)
Rahul kumar
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
devidkumar

Get to know the seller

Seller avatar
devidkumar delhi technical university
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions