Python Codes Basic to Advance
2.65K subscribers
82 photos
5 videos
8 files
100 links
Python Codes Basic to Advance

All Codes
@C_Codes_pro
@CPP_Codes_pro
@Java_Codes_Pro
@nodejs_codes_pro

Discussion
@bca_mca_btech
Download Telegram
#3 Creating variables & Adding

var1 = 5 # Variable 1
var2 = 7 # Variable 2

print (var1, '+', var2, '=', var1 + var2)
# Showing Add Result
Output ๐Ÿ‘† of {This Program}
๐Ÿ‘6๐Ÿ‘4
#5 Arrays[Basically List] in Python

arr = [2, 3, 5] # initialized Array

print(arr[0] ) # printing 1st element
print(arr[1] ) # printing 2nd element
๐Ÿ‘5
in Python array doesn't exists but
You can import its functionality by

Writing this ๐Ÿ‘‡
import array

And use array like this format ๐Ÿ‘‡
variable_name = array(typecode,[elements])
Here You can see type code used in virtual array

Array declaration ๐Ÿ‘‡(also import this module)
variable_name = array(typecode,[elements])
๐Ÿ‘1
#6 Arrays in Python (virtual)

import array as arr

numbers = arr.array('i',[10,20,30])

print(numbers[0]) # gets the 1st element
print(numbers[1]) # gets the 2nd element
print(numbers[2]) # gets the 3rd element

#output

#10
#20
#30
๐Ÿ‘7๐Ÿ‘1
Jiske pass Laptop nhi hai ๐Ÿ‘‡
Mobile best Compiler's

C Compiler Click Here
C++ Compiler Click Here
Python Compiler Click Here
Java Compiler Click Here
Sql Compiler Click Here

Universal Compilers for mobile

Replit (web or app) Click Here
Jdoodle(web or app) Click Here
Programize (web) Search web

For any help Freely Say here
๐Ÿ‘2
Now you can compile your codes by @CodeCompiler_bot

Come in @IO_Coding or @bca_group_pro for Compilation of your code
"""
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
๐Ÿ‘11
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
๐Ÿ‘4โค1
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
โค1
Python Codes Basic to Advance pinned ยซAll Codes @C_Code5 @CPP_Coding @Python_Codes_Pro @Java_Codes_Pro @jsCode0 Discussion @bca_mca_btechยป
Ye directly run karne ka way kaisa laga ?
If you want any bot which will run codes in your group you can freely use @CodeCompiler_Bot

๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ˜ keep studying....
my_set = {1, 2, 3}
for item in my_set:
    print(item)
set1 = {1, 2, 3}
set2 = {3, 4, 5}
union_set = set1.union(set2)
print(union_set)
my_set = {1, 2, 3}
if 3 in my_set:
    print("The item is in the set.")

# discussion @bca_mca_btech