Python Projects & Resources
56.7K subscribers
778 photos
342 files
328 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
10. append()

Whether you're delving into web development or machine learning with Python, append() is another Python method you'll often need. It works by writing new data into a list without overwriting its original content.

The example below multiplies each item in a range of integers by three and writes them into an existing list:

nums = [1, 2, 3]
appendedlist = [2, 4]
for i in nums:
a = i*3
appendedlist.append(a)
print(appendedlist)

Output:[2, 4, 3, 6, 9]
👍2
11. range()

You might already be familiar with range() in Python. It's handy if you want to create a list of integers ranging between specific numbers without explicitly writing them out.

Let's create a list of the odd numbers between one and five using this function:

a = range(1, 6)
b = []
for i in a:
if i%2!=0:
b.append(i)
print(b)

Output: [1, 3, 5]
🔥6👍1
12. slice()

Although the slice() function and the traditional slice method give similar outputs, using slice() in your code can make it more readable.

You can slice any mutable iterable using the slice method:

b = [1, 3, 4, 6, 7, 10]
st = "Python tutorial"
sliceportion = slice(0, 4)
print(b[sliceportion])
print(st[sliceportion])

Output:
[1, 3, 4, 6]
Pyth

The above code gives a similar output when you use the traditional method below:

print(b[0:4])
print(st[0:4])
🔥4👍2
13. format()

The format() method lets you manipulate your string output. Here's how it works:

multiple = 5*2
multiple2 = 7*2
a = "{} is the multiple of 5 and 2, but {} is for 7 and 2"
a = a.format(multiple, multiple2)
print(a)

Output:
10 is the multiple of 5 and 2, but 14 is for 7 and 2
🔥5
14. strip()

Python's strip() removes leading characters from a string. It repeatedly removes the first character from the string, if it matches any of the supplied characters.

If you don't specify a character, strip removes all leading whitespace characters from the string.

The example code below removes the letter P and the space before it from the string:

st = " Python tutorial"
st = st.strip(" P")
print(st)

Output: ython tutorial

You can replace (" P") with ("P") to see what happens.
🔥4👍2
15. abs()

Do you want to neutralize negative mathematical outputs? Then try out the abs() function. It can come in handy in computational programming or data science operations.

See the example below for how it works:

neg = 4 - 9
pos = abs(neg)
print(pos)

Output: 5
🔥2
16. upper()

As the name implies, the upper() method converts string characters into their uppercase equivalent:

y = "Python tutorial"
y = y.upper()
print(y)

Output: PYTHON TUTORIAL
👍2🔥2
17. lower()

You guessed right! Python's lower() is the opposite of upper(). So it converts string characters to lowercases:

y = "PYTHON TUTORIAL"
y = y.lower()
print(y)

Output: python tutorial
👍2🔥2
18. sorted()

The sorted() function works by making a list from an iterable and then arranging its values in descending or ascending order:

f = {1, 4, 9, 3} # Try it on a set
sort = {"G":8, "A":5, "B":9, "F":3} # Try it on a dictionary
print(sorted(f, reverse=True)) # Descending
print(sorted(sort.values())) # Ascending (default)

Output:
[9, 4, 3, 1]
[3, 5, 8, 9]
🔥2
19. join()

The join() function lets you merge string items in a list.

You only need to specify a delimiter and the target list to use it:

a = ["Python", "tutorial", "on", "MUO"]
a = " ".join(a)
print(a)

Output: Python tutorial on MUO
🔥2👍1
20. replace()

Python's replace() method lets you replace some parts of a string with another character. It's often handy in data science, especially during data cleaning.
The replace() method accepts two parameters: the replaced character and the one you'll like to replace it with.

Here's how it works:

columns = ["Cart_name", "First_name", "Last_name"]
for i in columns:
i = i.replace("_", " ")
print(i)

Output:
Cart name
First name
Last name
👍2🔥2
What is the difference between append() and extend() methods?

Both append() and extend() methods are methods used to add elements at the end of a list.

👉append(element): Adds the given element at the end of the list that called this append() method

👉extend(another-list): Adds the elements of another list at the end of the list that called this extend() method
2👍2🔥1
​​Python Learning Courses provided by Microsoft 📚

Recently, I found out that Microsoft provides quality online courses related to Python on Microsoft Learn.
Microsoft Learn is a free online platform that provides access to a set of training courses for the acquisition and improvement of digital skills. Each course is designed as a module, each module contains different lessons and exercises. Below are the modules related to Python learning.

🟢Beginner
1
. What is Python?
2. Introduction to Python
3. Take your first steps with Python
4. Set up your Python beginner development environment with Visual Studio Code
5. Branch code execution with the if...elif...else statement in Python
6. Manipulate and format string data for display in Python
7. Perform mathematical operations on numeric data in Python
8. Iterate through code blocks by using the while statement
9. Import standard library modules to add features to Python programs
10. Create reusable functionality with functions in Python
11. Manage a sequence of data by using Python lists
12. Write basic Python in Notebooks
13. Count the number of Moon rocks by type using Python
14. Code control statements in Python
15. Introduction to Python for space exploration
16. Install coding tools for Python development
17. Discover the role of Python in space exploration
18. Crack the code and reveal a secret with Python and Visual Studio Code
19. Introduction to object-oriented programming with Python
20. Use Python basics to solve mysteries and find answers
21. Predict meteor showers by using Python and Visual Studio Code
22. Plan a Moon mission by using Python pandas

🟠Intermediate
1. Create machine learning models
2. Explore and analyze data with Python
3. Build an AI web app by using Python and Flask
4. Get started with Django
5. Architect full-stack applications and automate deployments with GitHub

#materials
👍9🔥51
C2Cpayment is the Crypto C2C trading platform! C2C is coin TO coin! C2C is consumer TO consumer!Click to start
👍1
Learning python by building games [ Packt ] by Sachin Kafle
👇👇
Python Basics: A Practical Introduction to Python 3
👇👇
👍1