Python Projects & Resources
56.8K subscribers
776 photos
342 files
327 links
Perfect channel to learn Python Programming ๐Ÿ‡ฎ๐Ÿ‡ณ
Download Free Books & Courses to master Python Programming
- โœ… Free Courses
- โœ… Projects
- โœ… Pdfs
- โœ… Bootcamps
- โœ… Notes

Admin: @Coderfun
Download Telegram
Data Analysis with Python and PySpark (Jonathan Rioux).pdf
14.6 MB
Data Analysis with Python and PySpark PDF
๐Ÿ‘4๐Ÿ‘1
Which programming language should I use on interview?

Companies usually let you choose, in which case you should use your most comfortable language. If you know a bunch of languages, prefer one that lets you express more with fewer characters and fewer lines of code, like Python or Ruby. It keeps your whiteboard cleaner.

Try to stick with the same language for the whole interview, but sometimes you might want to switch languages for a question. E.g., processing a file line by line will be far easier in Python than in C++.

Sometimes, though, your interviewer will do this thing where they have a pet question thatโ€™s, for example, C-specific. If you list C on your resume, theyโ€™ll ask it.

So keep that in mind! If youโ€™re not confident with a language, make that clear on your resume. Put your less-strong languages under a header like โ€˜Working Knowledge.โ€™
๐Ÿ‘12โค6
Robust_Python_Write_Clean_and_Maintainable_Code_Patrick_Viafore.pdf
7.2 MB
Robust Python: Write Clean and Maintainable Code PDF
๐Ÿ‘7๐Ÿ‘1
What are python namespaces?

๐Ÿ‘‰A Python namespace ensures that object names in a program are unique and can be used without any conflict. Python implements these namespaces as dictionaries with โ€˜name as keyโ€™ mapped to its respective โ€˜object as valueโ€™.

Letโ€™s explore some examples of namespaces:

๐Ÿ‘‰Local Namespace consists of local names inside a function. It is temporarily created for a function call and gets cleared once the function returns.

๐Ÿ‘‰Global Namespace consists of names from various imported modules/packages that are being used in the ongoing project. It is created once the package is imported into the script and survives till the execution of the script.

๐Ÿ‘‰Built-in Namespace consists of built-in functions of core Python and dedicated built-in names for various types of exceptions.
๐Ÿ‘8
Inheritance in Python with an example?

๐Ÿ‘‰As Python follows an object-oriented programming paradigm, classes in Python have the ability to inherit the properties of another class. This process is known as inheritance. Inheritance provides the code reusability feature. The class that is being inherited is called a superclass or the parent class, and the class that inherits the superclass is called a derived or child class. The following types of inheritance are supported in Python:

๐Ÿ‘‰
Single inheritance: When a class inherits only one superclass

๐Ÿ‘‰Multiple inheritance: When a class inherits multiple superclasses

๐Ÿ‘‰Multilevel inheritance: When a class inherits a superclass, and then another class inherits this derived class forming a โ€˜parent, child, and grandchildโ€™ class structure

๐Ÿ‘‰Hierarchical inheritance: When one superclass is inherited by multiple derived classes
๐Ÿ‘10
What are the common built-in data types in Python?

Python supports the below-mentioned built-in data types:

Immutable data types:

๐Ÿ‘‰Number
๐Ÿ‘‰String
๐Ÿ‘‰Tuple

Mutable data types:

๐Ÿ‘‰List
๐Ÿ‘‰Dictionary
๐Ÿ‘‰set
๐Ÿ‘10๐Ÿ”ฅ7โค1
What is the lambda function in Python?

A lambda function is an anonymous function (a function that does not have a name) in Python. To define anonymous functions, we use the โ€˜lambdaโ€™ keyword instead of the โ€˜defโ€™ keyword, hence the name โ€˜lambda functionโ€™. Lambda functions can have any number of arguments but only one statement.

Example:

l = lambda x,y : x*y
print(a(5, 6))

Output:30
๐Ÿ‘19โค2
Here's a list of 20 valuable built-in Python functions and methods that shorten your code and improve its efficiency.
โค10๐Ÿ‘1
1. reduce()

Python's reduce() function iterates over each item in a list, or any other iterable data type, and returns a single value. It's one of the methods of the built-in functools class of Python.

Here's an example of how to use reduce:

from functools import reduce
def add_num(a, b):
return a+b
a = [1, 2, 3, 10]
print(reduce(add_num, a))

Output: 16

You can also format a list of strings using the reduce() function:

from functools import reduce
def add_str(a,b):
return a+' '+b
a = ['MUO', 'is', 'a', 'media', 'website']
print(reduce(add_str, a))

Output: MUO is a media website
โค6๐Ÿ‘2
2. split()

The split() function breaks a string based on set criteria. You can use it to split a string value from a web form. Or you can even use it to count the number of words in a piece of text.

The example code below splits a list wherever there's a space:

words = "column1 column2 column3"
words = words.split(" ")
print(words)

Output: ['column1', 'column2', 'column3']
๐Ÿ‘2
3. enumerate()

The enumerate() function returns the length of an iterable and loops through its items simultaneously. Thus, while printing each item in an iterable data type, it simultaneously outputs its index.

Assume that you want a user to see the list of items available in your database. You can pass them into a list and use the enumerate() function to return this as a numbered list.

Here's how you can achieve this using the enumerate() method:

fruits = ["grape", "apple", "mango"]
for i, j in enumerate(fruits):
print(i, j)

Output:
0 grape
1 apple
2 mango

Whereas, you might've wasted valuable time using the following method to achieve this:

fruits = ["grape", "apple", "mango"]
for i in range(len(fruits)):
print(i, fruits[i])

In addition to being faster, enumerating the list lets you customize how your numbered items come through.

In essence, you can decide to start numbering from one instead of zero, by including a start parameter:

for i, j in enumerate(fruits, start=1):
print(i, j)

Output:
1 grape
2 apple
3 mango
๐Ÿ‘8
4. eval()

Python's eval() function lets you perform mathematical operations on integers or floats, even in their string forms. It's often helpful if a mathematical calculation is in a string format.

Here's how it works:

g = "(4 * 5)/4"
d = eval(g)
print(d)

Output: 5.0
๐Ÿ‘3
5. round()

You can round up the result of a mathematical operation to a specific number of significant figures using round():

raw_average = (4+5+7/3)
rounded_average=round(raw_average, 2)
print("The raw average is:", raw_average)
print("The rounded average is:", rounded_average)

Output:
The raw average is: 11.333333333333334
The rounded average is: 11.33
๐Ÿ‘1