Sample Lab Orientation in Python orientation

NandhiniSakthivel6 14 views 16 slides Jul 10, 2024
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

Sample copy


Slide Content

Towrite,test,anddebugsimplePythonprograms.
ToimplementPythonprogramswithconditionals
andloops.

UsefunctionsforstructuringPythonprograms.
RepresentcompounddatausingPythonlists,
tuples,dictionaries.
Readandwritedatafrom/tofilesinPython.

1.ComputetheGCDoftwonumbers.
2.Findthesquarerootofanumber(Newton‘s
method)
3.Exponentiation(powerofanumber)
4.Findthemaximumofalistofnumbers
5.LinearsearchandBinarysearch
6.Selectionsort,Insertionsort
7.Mergesort

8.Firstnprimenumbers
9.Multiplymatrices
10.Programsthattakecommandlinearguments
(wordcount)
11.Findthemostfrequentwordsinatextreadfroma
file
12.SimulateellipticalorbitsinPygame
13.SimulatebouncingballusingPygame

PythonisafairlyoldlanguagecreatedbyGuidoVan
Rossum.Thedesignbeganinthelate1980sandwas
firstreleasedinFebruary1991.
Pythonisanopensource,object-oriented,high-level
powerfulprogramminglanguage.

Thesyntaxofthelanguageiscleanandlengthofthe
codeisrelativelyshort.
Ithassimpleeasy-to-usesyntax.It'seasierto
understandandwritePythoncode.
ItcanbeeasilyintegratedwithC,C++,COM,ActiveX,
CORBA,andJava.

Web Development.
Graphical User Interfaces
Internet scripting.
Embedded scripting.
Database access and programming.
Game programming.

Python program prints Hello, world!
print('Hello, world!')
OUTPUT:
Hello, world!

Pythoncaneasilyguessthatthisprogramaddstwo
numbersandprintsit.
a = 2
b = 3
sum = a + b
print(sum)

Python program to find square root:
#!/usr/bin/python import math -//import mathmodule
print "math.sqrt(100) : ", math.sqrt(100)
print "math.sqrt(7) : ", math.sqrt(7)
When we run above program, it produces following result:
math.sqrt(100) : 10.0
math.sqrt(7) : 2.64575131106

ProblemDescription:
TheprogramtakestwonumbersandprintstheGCDof
twonumbers.
Algorithm:
1.Importthefractionsmodule.
2.Takeinboththeintegersandstoreitinseparate
variables.
3.Usethein-builtfunctiontofindtheGCDofboththe
numbers.
4.PrinttheGCD.
5.Stop.

import fractions a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
print("The GCD of the two numbers is",fractions.gcd(a,b))

Enter the first number:15
Enter the second number:5
The GCD of the two numbers is 5

PygameisacrossplatformsetofPythonmodules
designedforwritingvideogames.
Itincludescomputergraphicsandsoundlibraries
designedtobeusedwiththePythonprogramming
language.

ALL THE
BEST
Tags