Python | Algorithms | Data Structures | Cyber ​​Security | Networks
38.6K subscribers
779 photos
23 videos
21 files
714 links
This channel is for Programmers, Coders, Software Engineers.

1) Python
2) django
3) python frameworks
4) Data Structures
5) Algorithms
6) DSA

Admin: @Hussein_Sheikho

Ad & Earn money form your channel:
https://telega.io/?r=nikapsOH
Download Telegram
#37. .startswith()
Returns True if the string starts with the specified value.

filename = "document.pdf"
print(filename.startswith("doc"))

True


#38. .endswith()
Returns True if the string ends with the specified value.

filename = "image.jpg"
print(filename.endswith(".jpg"))

True


#39. .find()
Searches the string for a specified value and returns the position of where it was found. Returns -1 if not found.

text = "hello world"
print(text.find("world"))

6


#40. f-string (Formatted String Literal)
A way to embed expressions inside string literals.

name = "Alice"
age = 30
print(f"{name} is {age} years old.")

Alice is 30 years old.

---
#Python #ListMethods #DataStructures

#41. .append()
Adds an element at the end of the list.

fruits = ['apple', 'banana']
fruits.append('cherry')
print(fruits)

['apple', 'banana', 'cherry']


#42. .pop()
Removes the element at the specified position.

fruits = ['apple', 'banana', 'cherry']
fruits.pop(1) # Removes 'banana'
print(fruits)

['apple', 'cherry']


#43. .remove()
Removes the first item with the specified value.

fruits = ['apple', 'banana', 'cherry', 'banana']
fruits.remove('banana')
print(fruits)

['apple', 'cherry', 'banana']


#44. .insert()
Adds an element at the specified position.

fruits = ['apple', 'cherry']
fruits.insert(1, 'banana')
print(fruits)

['apple', 'banana', 'cherry']


#45. .sort()
Sorts the list in place.

numbers = [3, 1, 5, 2]
numbers.sort()
print(numbers)

[1, 2, 3, 5]

---
#Python #DictionaryMethods #DataStructures

#46. dict()
Creates a dictionary.

my_dict = dict(name="John", age=36)
print(my_dict)

{'name': 'John', 'age': 36}


#47. .keys()
Returns a view object displaying a list of all the keys in the dictionary.

person = {'name': 'Alice', 'age': 25}
print(person.keys())

dict_keys(['name', 'age'])


#48. .values()
Returns a view object displaying a list of all the values in the dictionary.

person = {'name': 'Alice', 'age': 25}
print(person.values())

dict_values(['Alice', 25])


#49. .items()
Returns a view object displaying a list of a given dictionary's key-value tuple pairs.

person = {'name': 'Alice', 'age': 25}
print(person.items())

dict_items([('name', 'Alice'), ('age', 25)])


#50. .get()
Returns the value of the specified key. Provides a default value if the key does not exist.

person = {'name': 'Alice', 'age': 25}
print(person.get('city', 'Unknown'))

Unknown

---
#Python #ErrorHandling #FileIO

#51. try, except
Used to handle errors and exceptions.