0% found this document useful (0 votes)
16 views3 pages

Methods and Funcions

The document defines common Python programming concepts including conditional statements like if/else/elif, loops like for and while, functions for iterating over sequences like range and enumerate, functions for working with iterables like zip, sorted, reversed, len, max, min, sum, any, all, filter, map, and the lambda function. It also covers common list methods like append, extend, insert, remove, pop, index, count, sort, reverse, copy, and clear.

Uploaded by

ahsan.talay
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)
16 views3 pages

Methods and Funcions

The document defines common Python programming concepts including conditional statements like if/else/elif, loops like for and while, functions for iterating over sequences like range and enumerate, functions for working with iterables like zip, sorted, reversed, len, max, min, sum, any, all, filter, map, and the lambda function. It also covers common list methods like append, extend, insert, remove, pop, index, count, sort, reverse, copy, and clear.

Uploaded by

ahsan.talay
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
You are on page 1/ 3

1.

if statement: Used to conditionally execute a block of code based on a specified


condition.
2. else statement: Used with an if statement to provide an alternative block of code to
execute when the condition is not met.
3. elif statement: Short for "else if," it allows you to specify additional conditions to be
checked if the initial if condition is not met.
4. for loop: Used to iterate over a sequence (such as a list, tuple, or string) and execute a
block of code for each element in the sequence.
5. while loop: Continuously executes a block of code as long as a specified condition is
True.
6. range(): Generates a sequence of numbers that can be used in for loops or to create
custom index-based iterations.
7. break: Used to exit a loop prematurely when a certain condition is met.
8. continue: Skips the rest of the current iteration of a loop and continues with the next
iteration.
9. pass: Placeholder statement that does nothing; used when a statement is syntactically
required but no action is needed.
10. enumerate(): Used with a for loop to iterate over both the index and value of elements
in an iterable.
11. zip(): Combines two or more iterables element-wise, creating an iterable of tuples.
12. sorted(): Returns a sorted version of an iterable or list.
13. reversed(): Returns a reversed version of an iterable or sequence.
14. len(): Returns the number of items in an iterable, such as a list or string.
15. max(): Returns the maximum value in an iterable.
16. min(): Returns the minimum value in an iterable.
17. sum(): Calculates the sum of all elements in an iterable, such as a list of numbers.
18. any(): Returns True if at least one element in an iterable evaluates to True.
19. all(): Returns True if all elements in an iterable evaluate to True.
20. filter(): Filters elements from an iterable based on a given function or condition.
21. map(): Applies a specified function to each element of an iterable and returns the
results as an iterable.
22. lambda: Used to define small, anonymous functions (also known as lambda functions)
inline.
append(): Adds an element to the end of a list.

extend(): Appends the elements of an iterable (e.g., another list) to the end of the list.

insert(): Inserts an element at a specified position in the list.

remove(): Removes the first occurrence of a specified element from the list.

pop(): Removes and returns the element at a specified index (or the last element if no index is
provided).

index(): Returns the index of the first occurrence of a specified element in the list.

count(): Returns the number of times a specified element appears in the list.

sort(): Sorts the elements of the list in ascending order (in-place).

reverse(): Reverses the order of elements in the list (in-place).

copy(): Creates a shallow copy of the list (new list with the same elements).

clear(): Removes all elements from the list, leaving it empty.

You might also like