Common techniques for using the set() function in Python:
1. Create a set from a list:
1. Create a set from a list:
my_list = [1, 2, 2, 3, 3, 3]
my_set = set(my_list)
2.Add an item to a set:my_set = {1, 2, 3}
my_set.add(4)
3.Remove an item from a set by its value:my_set = {1, 2, 3}
my_set.remove(3)
4.Check if an item is in a set:my_set = {1, 2, 3}
if 3 in my_set:
print("The item is in the set.")
5.Get the length of a set:my_set = {1, 2, 3}
set_length = len(my_set)
6.Loop through the items in a set:my_set = {1, 2, 3}
for item in my_set:
print(item)
7.Get the union of two sets:set1 = {1, 2, 3}
set2 = {3, 4, 5}
union_set = set1.union(set2)
8.Get the intersection of two sets:set1 = {1, 2, 3}
set2 = {3, 4, 5}
intersection_set = set1.intersection(set2)
๐20
Common techniques for using the zip() function in Python:
1. Zip two lists together:
1. Zip two lists together:
list1 = [1, 2, 3]
list2 = [4, 5, 6]
zipped_lists = zip(list1, list2)
2. Unzip a zipped list:zipped_lists = [(1, 4), (2, 5), (3, 6)]
list1, list2 = zip(*zipped_lists)
3. Loop through a zipped list:zipped_lists = [(1, 4), (2, 5), (3, 6)]
for item1, item2 in zipped_lists:
print(item1, item2)
4.Convert a zipped list to a dictionary:zipped_lists = [(1, 4), (2, 5), (3, 6)]
my_dict = dict(zipped_lists)
5. Zip three or more lists together:list1 = [1, 2, 3]
list2 = [4, 5, 6]
list3 = [7, 8, 9]
zipped_lists = zip(list1, list2, list3)
๐8
In general, the Python standard library includes many built-in functions that are available to use in your code without needing to import any additional modules. Some common examples of built-in functions include:
๐๐ป abs() : Returns the absolute value of a number.
๐๐ป all() : Returns True if all elements of an iterable are True, and False otherwise.
๐๐ป any() : Returns True if any element of an iterable is True, and False otherwise.
๐๐ป bin() : Converts an integer to a binary string.
๐๐ป bool() : Converts a value to a Boolean.
๐๐ป chr() : Returns the string representation of a Unicode character.
๐๐ป dir() : Returns a list of attributes and methods for an object.
๐๐ปenumerate(): Returns an enumerate object, which contains a sequence of tuples containing the index and value of each element of an iterable.
๐๐ป filter() : Returns an iterator for elements of an iterable for which a condition is True.
๐๐ป float() : Converts a value to a floating-point number.
๐๐ป format(): Formats a string using format specifiers.
๐๐ป hash() : Returns the hash value of an object.
๐๐ป int() : Converts a value to an integer.
๐๐ป isinstance(): Returns True if an object is an instance of a given type, and False otherwise.
๐๐ป len() : Returns the length of an object.
๐๐ป list() : Converts an iterable to a list.
๐๐ป map() : Returns an iterator that applies a function to each element of an iterable.
๐๐ป max() : Returns the maximum value of an iterable.
๐๐ป min() : Returns the minimum value of an iterable.
๐๐ป next() : Returns the next element of an iterator.
๐๐ป open() : Opens a file and returns a file object.
๐๐ป ord() : Returns the Unicode code point for a character.
๐๐ป print() : Prints a message to the standard output.
๐๐ป range() : Returns a sequence of numbers.
๐๐ป repr() : Returns a string representation of an object.
๐๐ป round() : Rounds a number to a specified number of decimal places.
๐๐ป set() : Creates a set object.
๐๐ป sorted() : Returns a sorted list from an iterable.
๐๐ป str() : Converts a value to a string.
๐๐ป sum() : Returns the sum of elements in an iterable.
๐๐ป type() : Returns the type of an object.
๐๐ป zip() : Returns an iterator that combines elements from multiple iterables.
๐๐ป abs() : Returns the absolute value of a number.
๐๐ป all() : Returns True if all elements of an iterable are True, and False otherwise.
๐๐ป any() : Returns True if any element of an iterable is True, and False otherwise.
๐๐ป bin() : Converts an integer to a binary string.
๐๐ป bool() : Converts a value to a Boolean.
๐๐ป chr() : Returns the string representation of a Unicode character.
๐๐ป dir() : Returns a list of attributes and methods for an object.
๐๐ปenumerate(): Returns an enumerate object, which contains a sequence of tuples containing the index and value of each element of an iterable.
๐๐ป filter() : Returns an iterator for elements of an iterable for which a condition is True.
๐๐ป float() : Converts a value to a floating-point number.
๐๐ป format(): Formats a string using format specifiers.
๐๐ป hash() : Returns the hash value of an object.
๐๐ป int() : Converts a value to an integer.
๐๐ป isinstance(): Returns True if an object is an instance of a given type, and False otherwise.
๐๐ป len() : Returns the length of an object.
๐๐ป list() : Converts an iterable to a list.
๐๐ป map() : Returns an iterator that applies a function to each element of an iterable.
๐๐ป max() : Returns the maximum value of an iterable.
๐๐ป min() : Returns the minimum value of an iterable.
๐๐ป next() : Returns the next element of an iterator.
๐๐ป open() : Opens a file and returns a file object.
๐๐ป ord() : Returns the Unicode code point for a character.
๐๐ป print() : Prints a message to the standard output.
๐๐ป range() : Returns a sequence of numbers.
๐๐ป repr() : Returns a string representation of an object.
๐๐ป round() : Rounds a number to a specified number of decimal places.
๐๐ป set() : Creates a set object.
๐๐ป sorted() : Returns a sorted list from an iterable.
๐๐ป str() : Converts a value to a string.
๐๐ป sum() : Returns the sum of elements in an iterable.
๐๐ป type() : Returns the type of an object.
๐๐ป zip() : Returns an iterator that combines elements from multiple iterables.
๐17โค1๐1
Forwarded from Data Analysis Books | Python | SQL | Excel | Artificial Intelligence | Power BI | Tableau | AI Resources
Python_programming_for_beginners_3_books_in_1_Beginner's.pdf
7.5 MB
Python programming for beginners
William Wizner, 2021
William Wizner, 2021
๐3
Python for beginners.pdf
2.1 MB
Python for Beginners
William Wizner, 2022
William Wizner, 2022
LEARN_PYTHON_PROGRAMMING_CRASH_COURSE_FOR_BIGINNERS.epub
38.9 MB
Learn Python Programming Crash Course for Beginners
Janani Sathish, 2021
Janani Sathish, 2021
๐3โค1
The_Complete_Python_Coding_&_Programming_Manual_15th_Edition_2022.pdf
77.8 MB
The Complete Python Coding Manual
bdm Publications, 2022
bdm Publications, 2022
๐7
Forwarded from Free Courses with Certificate - Python Programming, Data Science, Java Coding, SQL, Web Development, AI, ML, ChatGPT Expert
FREE RESOURCES TO LEARN PYTHON
๐๐
Free Udacity Course to learn Python
https://imp.i115008.net/5bK93j
Data Structure and OOPS in Python Free Courses
https://bit.ly/3t1WEBt
Free Certified Python course by Freecodecamp
https://www.freecodecamp.org/learn/scientific-computing-with-python/
Free Python Course from Google
https://developers.google.com/edu/python
Free Python Tutorials from Kaggle
https://www.kaggle.com/learn/python
Python hands-on Project
https://t.iss.one/Programming_experts/23
Free Python Books Collection
https://cfm.ehu.es/ricardo/docs/python/Learning_Python.pdf
https://static.realpython.com/python-basics-sample-chapters.pdf
๐จโ๐ปWebsites to Practice Python
1. https://codingbat.com/python
2. https://www.hackerrank.com/
3. https://www.hackerearth.com/practice/
4. https://projecteuler.net/archives
5. https://www.codeabbey.com/index/task_list
6. https://www.pythonchallenge.com/
Beginner's guide to Python Free Book
https://t.iss.one/pythondevelopersindia/144
Official Documentation
https://docs.python.org/3/
Join @free4unow_backup for more free courses
ENJOY LEARNING ๐๐
๐๐
Free Udacity Course to learn Python
https://imp.i115008.net/5bK93j
Data Structure and OOPS in Python Free Courses
https://bit.ly/3t1WEBt
Free Certified Python course by Freecodecamp
https://www.freecodecamp.org/learn/scientific-computing-with-python/
Free Python Course from Google
https://developers.google.com/edu/python
Free Python Tutorials from Kaggle
https://www.kaggle.com/learn/python
Python hands-on Project
https://t.iss.one/Programming_experts/23
Free Python Books Collection
https://cfm.ehu.es/ricardo/docs/python/Learning_Python.pdf
https://static.realpython.com/python-basics-sample-chapters.pdf
๐จโ๐ปWebsites to Practice Python
1. https://codingbat.com/python
2. https://www.hackerrank.com/
3. https://www.hackerearth.com/practice/
4. https://projecteuler.net/archives
5. https://www.codeabbey.com/index/task_list
6. https://www.pythonchallenge.com/
Beginner's guide to Python Free Book
https://t.iss.one/pythondevelopersindia/144
Official Documentation
https://docs.python.org/3/
Join @free4unow_backup for more free courses
ENJOY LEARNING ๐๐
๐10๐1