BHARANI PARK MATRIC HR SEC SCHOOL
JUMP STATEMENTS IN PYTHON
Definition:
Jump statements are used to transfer control from one part of the program to another.
Types of Jump Statements:
1. break
2. continue
3. pass
1. Break Statement:
- Terminates the loop completely.
- Control moves to the next statement after the loop.
Syntax: break
Example:
for word in "Jump Statement":
if word == "e":
break
2. Continue Statement:
- Skips the current iteration.
- Moves to the next iteration of the loop.
Syntax: continue
Example:
for word in "Jump Statement":
if word == "e":
continue
3. Pass Statement:
- It is a null statement.
- It does nothing when executed.
- Used as a placeholder.
Syntax: pass
Example:
for val in "Computers":
pass
print("End of the loop")
Bharani Park Matric Hr Sec School
Computer Science
Explain different types of Arguments (Function Arguments)
Types of Function Arguments:
• Required Argument
• Keyword Argument
• Default Argument
• Variable-length Argument
Required Arguments:
"Required Arguments" are the arguments passed to a function in correct positional order.
Example:
def PrintString(str):
print("Example - Required arguments")
print(str)
return
PrintString("welcome")
Keyword Arguments:
Keyword arguments will invoke the function after the parameters are recognized by their parameter
names.
Example:
def Printdata(name):
print("Keyword argument")
print("Name :", name)
return
Printdata(name = "Bharani")
Default Argument:
The argument that takes a default value if no value is provided in the function call.
Example:
def Printinfo(name, salary = 3500):
print("Name :", name)
print("Salary :", salary)
return
Printinfo("Mani")
Output:
Name : Mani
Salary : 3500
Variable-length Argument:
Variable-length arguments are not specified in the function definition and an asterisk (*) is used to
define variable-length argument.
Example:
def Printnos(*n):
for i in n:
print(i)
return
Syntax:
def function_name(*args):
function body
return
Bharani Park Matric Hr Sec School
Deleting elements from a list:
Deleting element from a list can be done by:
i) del statement
ii) remove()
iii) pop()
iv) clear()
del statement:
del statement is used to delete elements whose index is known.
Syntax:
del list[index of an element]
del list[index from : index to]
del list
Eg:
mark = [10, 20, 30, 40, 50]
del mark[1]
print(mark)
[10, 30, 40, 50]
remove():
remove() is used to delete elements of a list if its index is unknown.
Syntax:
[Link](element)
Eg:
mark = [10, 20, 30, 40, 50]
[Link](10)
pop():
pop() function can also be used to delete an element using the given index value.
pop() function deletes and returns the last element of a list if index is not given.
pop() function used to delete only one element.
Syntax:
[Link](index of an element)
Eg:
mark = [10, 20, 30, 40, 50]
[Link](1)
clear():
clear() is used to delete all the elements in a list.
it delete only the elements and retains the list.
Syntax:
[Link]()
Bharani Park Matric Hr Sec School
Different Types of Data Types
Built in or fundamental Data types
Number, String, Boolean, Tuple, List, Set, Dictionary
Numeric data type:
built in number object in Python supports integers, floating point numbers and complex numbers.
Examples:
Integer: 10, -25
Float: 12.5, 0.75
Complex: 2+3j
Integer → Integers can be decimal, octal or hexadecimal.
Octal integers use digit 0 followed by 'o' to denote octal digits.
Ex: 0o432
Hexadecimal use 0x
Eg: 0x876
Extra Example: Decimal → 123
Floating point: Sequence of decimal digits including decimal points.
Eg: 123.34
Extra Example: 0.5, 45.678
Exponent: An exponent data contains decimal digit part, decimal point, exponent part followed by
one or more digits.
Eg: 12E04
Extra Example: 1.2e3
Boolean data type:
Boolean data type have only two values true or false.
Example: 5 > 2 → True
String data type:
Data can be enclosed in single, double or triple quotes.
Examples:
'Hello'
"Python"
'''Multi line'''