Wallet Install
Home
Explore
Wallet
Video
Profile
Trends
English
- - Author on ShareChat
-
657 views • 5 months ago
#python
० % ೦: main py main py ஃ Output Output y{"n":3,"a":4, 8":1,"r":1,"]":1,"u":1 {'n' : 'a' : 4, ৪' : 1, 'r' : 1, 'j' : 1, 'u' : 3 , "٧":2,"1":3,"9" :2} C" : 1 ," j " : 3 , 'C': 1, '1 ' : q' : V' : 2 , '1' : 3 , 3 print(y) 2} [4 , 3 , 2, 2, 1, 1, 1, 1, 1] 7={} 3 , 3, Tesorted(list(y.values() ) ,reverse-True) print(T) result-T[4]  2 print(result) {'v' : 2 , 'q' : 2} 2={} in y 1tems(): for code Execution Successful K,V (ಕ   10 1f V==resu1t: 11 print(k,V) 12 z[k]=V int(z)  13 pr 14 ० % ೦: main py main py ஃ Output Output y{"n":3,"a":4, 8":1,"r":1,"]":1,"u":1 {'n' : 'a' : 4, ৪' : 1, 'r' : 1, 'j' : 1, 'u' : 3 , "٧":2,"1":3,"9" :2} C" : 1 ," j " : 3 , 'C': 1, '1 ' : q' : V' : 2 , '1' : 3 , 3 print(y) 2} [4 , 3 , 2, 2, 1, 1, 1, 1, 1] 7={} 3 , 3, Tesorted(list(y.values() ) ,reverse-True) print(T) result-T[4]  2 print(result) {'v' : 2 , 'q' : 2} 2={} in y 1tems(): for code Execution Successful K,V (ಕ   10 1f V==resu1t: 11 print(k,V) 12 z[k]=V int(z)  13 pr 14
10 likes
12 shares

More like this

  • - - Author on ShareChat
    -
    #python
    dictionary:| Your samel Python { "a" : "d" : 6 W C" : 3 "b " 5 "e" 4 $ ಕ  "f" : १ , 8} # step  pic but (Same 1 & 2 your a$ descending) sorted ( 1is t ( $ . values ( ) ) reverse-Truel X print(x) t = {} ( same matching 1ogic # step 3 & 4 a5 Your pic) for n V X : for in $ . items ( ) : 1, ] 1f ] '  V : t[i] ] "  print(t) Output Python [8 6 | 5 4 3 1 ] ' d ' : ' C ' : { ٤ : 8 a' : 6 b ' : 5 4 | 3 1 } "e " dictionary:| Your samel Python { "a" : "d" : 6 W C" : 3 "b " 5 "e" 4 $ ಕ  "f" : १ , 8} # step  pic but (Same 1 & 2 your a$ descending) sorted ( 1is t ( $ . values ( ) ) reverse-Truel X print(x) t = {} ( same matching 1ogic # step 3 & 4 a5 Your pic) for n V X : for in $ . items ( ) : 1, ] 1f ] '  V : t[i] ] "  print(t) Output Python [8 6 | 5 4 3 1 ] ' d ' : ' C ' : { ٤ : 8 a' : 6 b ' : 5 4 | 3 1 } "e "
    13
    12
  • - - Author on ShareChat
    -
    #python
    Corrected code (minimal change;| method) same Copy Python code import groupby itertools from "fffgghhdddrrrdagggccccgd" X 'ಕ result groupby(x ) : for char in group len(list(group) ) count # always str ( count ) Fesu1t char + add count print(result) Output Copy code f3g2h2d3r3d1a1g3c4g1d1 Corrected code (minimal change;| method) same Copy Python code import groupby itertools from "fffgghhdddrrrdagggccccgd" X 'ಕ result groupby(x ) : for char in group len(list(group) ) count # always str ( count ) Fesu1t char + add count print(result) Output Copy code f3g2h2d3r3d1a1g3c4g1d1
    14
    7
  • - - Author on ShareChat
    -
    #python
    X={"a":1,"b":2,"c":3,"d":4} want delete final element But i 1 dont know last element there in X. Python dictionaries keep insertion order In (Python 3.7+). So you can remove the last] key inserted element even if you dont know its Method 1: Using popitem( ) (Best way) Copy Python codel {"a" :1,"b" :2,"c" :3,"d" :4} X = X.popitem( ) print(x) Output Copy Python codel b' : 2 , {'a' : 'C' : 3} १ , X={"a":1,"b":2,"c":3,"d":4} want delete final element But i 1 dont know last element there in X. Python dictionaries keep insertion order In (Python 3.7+). So you can remove the last] key inserted element even if you dont know its Method 1: Using popitem( ) (Best way) Copy Python codel {"a" :1,"b" :2,"c" :3,"d" :4} X = X.popitem( ) print(x) Output Copy Python codel b' : 2 , {'a' : 'C' : 3} १ ,
    52
    104
  • - - Author on ShareChat
    -
    #python
    simple definition Polymorphism in Python Polymorphism means the same function or] method name can work in different ways for different objects: simple definition Polymorphism in Python Polymorphism means the same function or] method name can work in different ways for different objects:
    12
    13
  • - - Author on ShareChat
    -
    #python everyone python learner's need to notice this
    mainpy mainpy Output Output 1ist1=[1,2,3,4,5] [16 , 25] list2= [] 16 25 for in range(0 ,5) : append(1ist1[1]**2) 1ist2. Code Execution Successfull === EEE[ print(list2[3:4]+list2[4:5]) int(" join(map(str ,list2[3:4] pr +list2[4:5]))) mainpy mainpy Output Output 1ist1=[1,2,3,4,5] [16 , 25] list2= [] 16 25 for in range(0 ,5) : append(1ist1[1]**2) 1ist2. Code Execution Successfull === EEE[ print(list2[3:4]+list2[4:5]) int(" join(map(str ,list2[3:4] pr +list2[4:5])))
    9
    17
  • - - Author on ShareChat
    -
    #python everyone python learner's need to notice this
    str1 "HelloWorldl 1 output 2 = 3 # Loop through in each Character thel 4 string in range(len(str1)): for 1 5 if 1==4 1==6 1 1 6 0 2 33 or 33 or or 1==8 1==9: 01 ori str1[i].upper() output 7 + 1st and the # Convert characters 3rd tol uppercasel else: 8 str1 [ ]] # Keep thel output 9 + the string it ०f L$ rest as 10 print(output ) 11 str1 "HelloWorldl 1 output 2 = 3 # Loop through in each Character thel 4 string in range(len(str1)): for 1 5 if 1==4 1==6 1 1 6 0 2 33 or 33 or or 1==8 1==9: 01 ori str1[i].upper() output 7 + 1st and the # Convert characters 3rd tol uppercasel else: 8 str1 [ ]] # Keep thel output 9 + the string it ०f L$ rest as 10 print(output ) 11
    7
    4
  • - - Author on ShareChat
    -
    #python ipaddress validation. So every one python learner's need to notice this
    Trogramiz Irogramiz Programiz PRO Programiz PRO Python Online Compiler Python Online Compiler main py "8: ಹ mainpy 0: Output Output input("enter the ip: the ip: TP enter ٥٠٦ ٠٦ ٠٦ IP. split ( " ['0' '1'] '1' '1', print(t) nol n = len(t) print(n) Code Execution Successfull f = and int(t[o] and int(t[0])!=0 10 ifl 88 )>=1:# first octet check in range(0 , 11 for n) : 12 1f int(t[i]) and int(t[1]) >= 255: = 13 f = f + 1 14 if ٤ 15 4: == r t y W e q print( "yes p 16 17else: print( "no " ) 18 d f  g h j k | a $ Trogramiz Irogramiz Programiz PRO Programiz PRO Python Online Compiler Python Online Compiler main py "8: ಹ mainpy 0: Output Output input("enter the ip: the ip: TP enter ٥٠٦ ٠٦ ٠٦ IP. split ( " ['0' '1'] '1' '1', print(t) nol n = len(t) print(n) Code Execution Successfull f = and int(t[o] and int(t[0])!=0 10 ifl 88 )>=1:# first octet check in range(0 , 11 for n) : 12 1f int(t[i]) and int(t[1]) >= 255: = 13 f = f + 1 14 if ٤ 15 4: == r t y W e q print( "yes p 16 17else: print( "no " ) 18 d f  g h j k | a $
    7
    10
  • - - Author on ShareChat
    -
    #python *arg and **args in python function
    def add(**arg): +419 112**KVar8s su-0 dcl demn(*args): foprintargs  for 1,] in arg items(): print(i,j) demo(10,20,30,40,50,60) Su-su+ ] print( sum) add(a=4,b=5 , C=6 ) 10 11 def add(**arg): +419 112**KVar8s su-0 dcl demn(*args): foprintargs  for 1,] in arg items(): print(i,j) demo(10,20,30,40,50,60) Su-su+ ] print( sum) add(a=4,b=5 , C=6 ) 10 11
    0
    13
  • - - Author on ShareChat
    -
    #python convert nested list into normal list using def function
    Programiz | Trogramiz Programiz PRO Programiz PRO Python Online Compiler| Python Online Compiler| : 0 main py min py ஃ Output Output 1  def flatten_list(nested) : [1, 2, 3, 4, 5] flat=[] for in nested: Code Execution Successful if isinstanceli,list): flat extend(flatten_list(i] )) else: flat.append(i) return(flat) 5]]]]| 10 nested [१ , [3, [2, [4, print(flatten_list(nested) ) 11 Programiz | Trogramiz Programiz PRO Programiz PRO Python Online Compiler| Python Online Compiler| : 0 main py min py ஃ Output Output 1  def flatten_list(nested) : [1, 2, 3, 4, 5] flat=[] for in nested: Code Execution Successful if isinstanceli,list): flat extend(flatten_list(i] )) else: flat.append(i) return(flat) 5]]]]| 10 nested [१ , [3, [2, [4, print(flatten_list(nested) ) 11
    9
    14
Home
Explore
Wallet
Video