0% found this document useful (0 votes)
17 views

Hema New

Uploaded by

anithaaluru99
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)
17 views

Hema New

Uploaded by

anithaaluru99
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
You are on page 1/ 20

Internship on Python Essentials:-

• INTERNSHIP INSTRUCTOR: CISCO NETWORKING ACADEMY


• Prepared by:- Hema Latha Thanniru
• Roll No :- 209E1A0298
AGENDA:-
● Introduction to Python.
● Features of python.
● Variables, objects and classes.
● Basic syntax rules.
● Functions.
● Data Types and Operators.
● Input/Output.
● Control , Looping Statements.
● Exceptions.
● Oops Concepts
● Type Conversions.
● Exception Handling.
● Applications of python.
What is Python?
● Python is a popular high-level programming language used in various
applications

○ Python is an easy language to learn because of its simple syntax.

○ Python can be used for simple tasks such as plotting or for more complex tasks like
machine learning
Features Of Python:-
● Easy
● Interpreted
● Object-oriented
● Free and open source
● Portable
● GUI Programming
● Large python library
Variables, Objects, and Classes (cont.)
● A class is a collection of objects
who share the same set of
variables/methods. Instance #1
Color: Pink
Name: Polo
○ The definition of the class provides a Instance #2
blueprint for all the objects within it Color: Red
Name: Mini
(instances).
Instance #3
Color: Blue
○ Instances may share the same Name: Beetle
variables (color, size, shape, etc.), but
they do NOT share the same values
for each variable (blue/red/pink,
small/large, square/circular etc.)
Basic Syntax Rules
● The name of your variable (myInt etc.) is placed on the left of the “=“ operator.

○ Most variable names are in camel case where the first word begins with a lowercase letter and any subsequent words
are capitalized

○ Variable names may also appear in snake case where all words are lowercase, with underscores between words
● The assignment operator (“=“) sets the variable name equal to the memory location where your value is found.
● The value of your variable (“Hello, World”) is placed on the right of the “=“ operator.

○ The type of this value does NOT need to be stated but its format must abide by a given object type (as shown).

myString = “Hello, World” myInt = 7


myFloat = 7.0
myList = [7, 8, 9] myBoolean = true
Basic Syntax Rules
● Function Syntax
○ def...: indicates that you are defining a new function.

○ function() refers to the name of your function. By convention, this name is typically lowercase and represents a verb/action.

○ a,b refers to parameters (values or variables) that can be used within the statements of your function’s definition (......). If
your function has no parameters, an empty parenthetical () is used.

○ The return statement is an optional statement that will return a value for your function to your original call.

def function(a, b):


......
return a + b
Common Data Types and Operators
● A data type is a means of classifying a value and determining what operations can
be performed on it. All objects have a data type.
● Operators are symbols used carry out specific functions/computations.
● https://www.youtube.com/watch?v=v5MR5JnKcZI
Input/Output

● Input functions (input()) allow users of a program to place values into


programming code.

○ The parameter for an input function is called a prompt. This is a


string (this can be indicated by “” or ‘’) such as “Enter a number: “
xString = input(“Enter a number: “)
○ The user’s response to the prompt will be returned to the input x = int(xString)
statement call as a string. To use this value as any other data type, y=x+2
it must be converted with another function (int()). print(y)
● Print functions (print()) allow programs to output strings to users on a
given interface.

○ The parameter of this function is of any type. All types will


automatically be converted to strings.
If-else Statements
● If-else statements allow programmers to adapt the function of their
code based on a given condition.
● If a given condition (i.e. x % 2 == 0) is true, then the statements
following the if statement (if) will be executed. If the condition is false, xString = input(“Enter a number: “)
the statements following the else statement (else) will be executed. x = int(xString)
if x % 2 == 0:
○ The condition is tested using the Boolean operators == (is equal print(“This is an even number”)
to), != (is not equal to), and (used to test multiple conditions), and
elif x == 0:
or (used to test if AT LEAST ONE condition is true).
print(“This number equals 0”)
else:
○ Additionally, else-if statements (elif) can be used to provide
print(“This is an odd number”)
unique coding statements for multiple conditions.
Loops in Python:-
● In Python Programming language the loops are used when we want to
perform a task in n of times there we have to use this concept in the form of
declaring variables.
● There are two types of loops in python programming Language:-
● While Loop
● For Loop
While Loops myString = input(“Enter a number: “)
myInt = int(myString)
● While loops are statements that iterate so long as a given x=0
Boolean condition is met. while x < 5:
print(myInt)
○ x (the variable determining whether or not the x= x +1
condition is met) is defined and manipulated
OUTSIDE of the header of the while loop (while)

○ The condition (x < 5) is a statement containing a


Boolean variable.

○ break is a statement used to exit the current


for/while loop.

○ continue is a statement used to reject all


statements in the current for/while loop iteration
and return to the beginning of the loop.
For Loops
● For loops perform the same task (iterate) for the number of
times specified by an iterable (something that can be evaluated
repeatedly such as a list, string, or range).
● for defines the for loop
● x is the variable defining the number of times the statements
within the loop (print(myInt)) are executed.
myString = input(“Enter a number: “)
● The range(start, stop, step) function is often used to define x.
myInt = int(myString)
○ The starting value is defined by start, the final value is
for x in range(0, 5, 1): print(myInt)
defined by stop – 1, and the magnitude at which x
changes between loops is defined by step.
● in is a Boolean operator that returns true if the given value (x) is
found within a given list, string, range etc.
Exceptions:-
Oops Concepts:-
● Inheritance : A mechanism for creating a new class based on an existing class,
inheriting its attributes and methods.
● Polymorphism: The ability of an object to take on multiple forms, achieved through
method overriding or method overloading.
● Encapsulation: Hiding internal implementation details of an object from the outside
world, exposing only necessary information through public methods.
● Abstraction: Focusing on essential features of an object, hiding non-essential details,
and showing only the necessary information to the outside world.
● Classes: A blueprint for creating objects, defining properties and methods.
Objects: Instances of classes, representing real-world entities
Type Conversion:-
Exception handling in Python:-
● Exception handling in Python is a mechanism to manage errors or
unexpected conditions that arise during the execution of a program.
● Goal: To prevent the program from crashing and to handle errors gracefully.

● Basic Syntax:-
● Try Block: Code that may potentially raise an exception is put inside a try
block.
● Example:-
Applications Of Python:-
Certificate:-

You might also like