0% found this document useful (0 votes)
3 views6 pages

Problem Solving Computer Programming Lab

Uploaded by

sakila
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Problem Solving Computer Programming Lab

Uploaded by

sakila
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Problem Solving Computer Programming Lab

✅ 1. Installing Python Environment (Instructions + Code Check)

Steps:

1. Download Python from: [Link]

2. Install and check "Add Python to PATH"

3. Verify installation using this code:

# Check Python installation

import sys

print("Python Version:", [Link])

print("Python installed successfully!")

✅ 2. Basic Arithmetic Operations Using Python Interpreter

# Basic Arithmetic Operations

a = 10

b=5

print("Addition:", a + b)

print("Subtraction:", a - b)

print("Multiplication:", a * b)

print("Division:", a / b)

print("Floor Division:", a // b)

print("Modulus:", a % b)
print("Exponent:", a ** b)

✅ 3. Working with Variables and Different Data Types

# Variables and Data Types

# Integer

x = 10

# Float

y = 3.14

# String

name = "Sakila"

# Boolean

is_student = True

# Display values and types

print("Integer value:", x, "Type:", type(x))

print("Float value:", y, "Type:", type(y))

print("String value:", name, "Type:", type(name))

print("Boolean value:", is_student, "Type:", type(is_student))

# Using variables in expressions

result = x + y
print("Result of x + y:", result)

# String concatenation

greeting = "Hello " + name

print(greeting)

Experiment 1: Installing Python


Environment

Aim

To install Python and set up the programming environment.

Software Required

 Python 3.x

 IDLE (comes with Python)

 VS Code (Optional)

Procedure

1. Download Python from the official website.

2. Run the installer.

3. Select Add Python to PATH.

4. Click Install Now.

5. Open Command Prompt.

6. Type:

python --version

7. If the version is displayed, Python is installed successfully.

8. Open IDLE from the Start Menu.


9. Type:

print("Hello, Python")

10. Press Enter.

Output

Hello, Python

Result

Python was installed successfully and the environment is ready for programming.

Experiment 2: Basic Arithmetic Operations Using Python Interpreter

Aim

To perform basic arithmetic operations using the Python Interpreter.

Theory

Python provides arithmetic operators to perform mathematical calculations.

Operator Meaning

+ Addition

- Subtraction

* Multiplication

/ Division

// Floor Division

% Modulus

** Exponent

Program

a = 20
b=6

print("Addition =", a + b)
print("Subtraction =", a - b)
print("Multiplication =", a * b)
print("Division =", a / b)
print("Floor Division =", a // b)
print("Modulus =", a % b)
print("Power =", a ** b)

Output

Addition = 26
Subtraction = 14
Multiplication = 120
Division = 3.3333333333333335
Floor Division = 3
Modulus = 2
Power = 64000000

Result

Arithmetic operations were performed successfully using the Python Interpreter.

Experiment 3: Working with Variables and Different Data Types

Aim

To declare variables of different data types and use them in expressions.

Theory

Python supports different data types such as:

Data Type Example

Integer 25

Float 95.6

String "Python"

Boolean True

Program

name = "Alice"
age = 21
height = 5.6
student = True

print("Name:", name)
print("Age:", age)
print("Height:", height)
print("Student:", student)

birth_year = 2025 - age


print("Birth Year:", birth_year)

height_cm = height * 30.48


print("Height in cm:", height_cm)

Output

Name: Alice
Age: 21
Height: 5.6
Student: True
Birth Year: 2004
Height in cm: 170.688

Result

Variables of different data types were created and used successfully in expressions.

You might also like