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

Experiment 1 Python

The document outlines the steps for installing Python and explains the differences between scripting and interactive modes in IDLE. It includes various programming tasks such as creating variables, performing arithmetic operations, and writing functions for mathematical computations. Additionally, it covers practical exercises like calculating the hypotenuse, finding simple interest, and manipulating data types.

Uploaded by

aryanxnn41
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

Experiment 1 Python

The document outlines the steps for installing Python and explains the differences between scripting and interactive modes in IDLE. It includes various programming tasks such as creating variables, performing arithmetic operations, and writing functions for mathematical computations. Additionally, it covers practical exercises like calculating the hypotenuse, finding simple interest, and manipulating data types.

Uploaded by

aryanxnn41
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

Experiment 1 name – Aryan Tomar Sap id – 590024536 Sub – Python lab

1.1Install Python and write the steps of installation and understand


difference between scripting and interactive modes in IDLE.

How to Install Python The process is straightforward, but there is one crucial checkbox you shouldn't
miss.

Download: Visit the official Python website and click the button to download the latest version for
your operating system (Windows, macOS, or Linux).

Run the Installer: Open the downloaded .exe or .pkg file.

Crucial Step: On Windows, look for a checkbox at the bottom that says "Add [Link] to PATH".

Verify: Open your terminal (Command Prompt on Windows or Terminal on Mac) and type python --
version. If it returns a version number, you're all set.

IDLE: Scripting vs. Interactive Mode

When you open IDLE (Python’s Integrated Development and Learning Environment), you have two
primary ways to write code. Understanding the difference is key to a smooth workflow.

1. Interactive Mode (The "Shell")

When you first launch IDLE, you are in Interactive Mode. You will see the >>> prompt.

 How it works: It executes code line-by-line. You type a command, hit Enter, and Python gives
you the result immediately.

 Best for: Testing small snippets of code, doing quick math, or checking how a specific
function works.

 Downside: Your code is not saved. Once you close the window, your work is gone.

2. Scripting Mode (The "Editor")

To enter Scripting Mode, go to File > New File in the IDLE menu. A blank window without the >>>
prompt will open.

 How it works: You write your entire program (multiple lines of code) first, save it as a .py file,
and then run it all at once by pressing F5.

 Best for: Building actual applications, automation scripts, and projects you want to share or
use later.

 Downside: You have to manually run the script to see the output, which will then appear
back in the Interactive Shell window.

1.2 Create a variable to store your age and print its type using type().
1.3 . Declare a string variable called x and assign it the value “Hello”. a. Print out the value of x

Output

1.4 . Take different data types and print values using print function.

Source code

Output
1.5 Declare these variables (x, y and z) as integers. Assign a value of 9 to x, Assign a value of 7 to
y, perform addition, multiplication, division and subtraction on these two variables and Print
out the result.

Source code

Output

1.6 Write a program to compute the length of the hypotenuse (c) of a right triangle using
Pythagoras theorem.

Source code

Output
1.7 Write a program to find simple interest

Source code

Output

1.8 Write a program to find area of triangle when length of sides are given.

Source code

Output

1.9 Write a program to convert given seconds into hours, minutes and remaining seconds.

Source code

Outpiut
1.10 Write a program to swap two numbers without taking additional variable.

Source code

Outpur

1.11 Write a program to find sum of first n natural numbers.


Source code

Output

1.12 Write a program to print truth table for bitwise operators (&, | and ^ operators)
Source code

Output
1.13 Write a program to find left shift and right shift values of a given number.

Source code

Output

1.14 Using membership operator find whether a given number is in sequence (10,20,56,78,89)

Source code

Output

You might also like