0% found this document useful (0 votes)
7 views2 pages

Python Lab 02

The document outlines a lab focused on programming fundamentals in Python, specifically covering comments, input/output statements, escape sequences, and basic programming concepts. It includes examples of using print() and input() functions, as well as type conversion and comments. Exercises and homework assignments are provided to reinforce learning, such as displaying personal information and calculating total marks from multiple subjects.

Uploaded by

Asmara Minhas
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)
7 views2 pages

Python Lab 02

The document outlines a lab focused on programming fundamentals in Python, specifically covering comments, input/output statements, escape sequences, and basic programming concepts. It includes examples of using print() and input() functions, as well as type conversion and comments. Exercises and homework assignments are provided to reinforce learning, such as displaying personal information and calculating total marks from multiple subjects.

Uploaded by

Asmara Minhas
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

Programming Fundamentals Lab (Python)

Lab 02 — Comments, Input, Output and Basic Programs

Objective

To familiarize students with comments, input/output statements, escape sequences and basic
Python programs.

Concepts

print() displays output on the screen.


print("Hello Students")
print(10)
print(3.14)
print(10+5)

input() takes value from keyboard.


name = input("Enter your name: ")
print(name)

Type conversion:
age = int(input("Enter age: "))

Comments

Single line comment:


# This is a comment

Multi line comment (docstring):


"""
This is
multi line
comment
"""

Examples
# Basic Program
print("Welcome to Programming Fundamentals Lab")
print("Python is easy to learn")

# Escape Characters
print("Hello\nStudents")
print("Name:\tAli")

# Addition Program
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Sum =", num1 + num2)
Exercises

1) Display your name, ID and course name

2) Print star diagram

Home Work

Take marks of six subjects and display total marks

You might also like