ar
Feedback
Python Codes Basic to Advance

Python Codes Basic to Advance

الذهاب إلى القناة على Telegram
2 813
المشتركون
لا توجد بيانات24 ساعات
-47 أيام
-2430 أيام
أرشيف المشاركات
/py my_set = {1, 2, 3} for item in my_set: print(item)

/py my_set = {1, 2, 3} for item in my_set: print(item)

Some function of list fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana'] #gives_count_of_apples fruits.count('apple') 2 fruits.count('tangerine') 0 #to_get_index_of_banana fruits.index('banana') 3 #Find_next_banana_starting_a_position_4 fruits.index('banana', 4) 6 #to_reverse_fruits_list fruits.reverse() fruits ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange'] #to_add_item_at_the_end_of_the_list fruits.append('grape') fruits ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange', 'grape'] #sort_the_fruits_list fruits.sort() fruits ['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear'] #to_delete_the_last_item_in_the_list fruits.pop() 'pear' // @python_codes_pro

Common techniques for using the set() function in Python: 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) // @python_codes_pro

""" Pattern:   * * * *    * * *     * *      *      *     * *    * * *   * * * * """ n = int(input("Enter no.: ")) for i in range(1, n):           print(" " * i , "* " * (n-i))           for i in range(1, n):           print(" " * (n - i ), "* " * i)                            # @Python_Codes_Pro

Now you can compile your codes by @CodeCompiler_bot Come in @IO_Coding or @bca_group_pro for Compilation of your code

Learn how to create Telegram Bot Also clear Javascript basics (Regular video Uploading...) https://youtube.com/playlist?list=PLjEYzWkdEvxvar65MToPfkA1x4CeZ_bNk