File tree Expand file tree Collapse file tree 7 files changed +84
-0
lines changed Expand file tree Collapse file tree 7 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ str = input ('please input ' )
2
+ count = 0
3
+ for i in reversed (str ):
4
+ if i == ' ' :
5
+ break
6
+ count += 1
7
+
8
+ print (count )
Original file line number Diff line number Diff line change
1
+ str = input ()
2
+ c = input ()
3
+ target = []
4
+ if ord (c ) >= ord ('a' ) and ord (c ) <= ord ('z' ):
5
+ target = [ c , chr (ord (c ) - 32 )]
6
+ elif ord (c ) >= ord ('A' ) and ord (c ) <= ord ('Z' ):
7
+ target = [ c , chr (ord (c ) + 32 )]
8
+ else :
9
+ target = [c ]
10
+
11
+ count = 0
12
+ for i in str :
13
+ if i in target :
14
+ count += 1
15
+
16
+ print (count )
Original file line number Diff line number Diff line change
1
+ n = input ()
2
+ target = []
3
+ for i in range (int (n )):
4
+ target .append (input ())
5
+
6
+ t = list (map (lambda x : int (x ) , target ))
7
+ unique_t = set (t )
8
+ # print('result:')
9
+ for i in sorted (unique_t ):
10
+ print (i )
Original file line number Diff line number Diff line change
1
+ str = input ()
2
+ if not str :
3
+ exit ()
4
+ result = []
5
+ # range 和 slice 都是属于含头不含尾
6
+ for i in range (0 , len (str ) , 8 ):
7
+ if i + 8 > len (str ) - 1 :
8
+ s = str [i : len (str )] + '0' * ( 8 - (len (str ) - i ))
9
+ else :
10
+ s = str [i :i + 8 ]
11
+ result .append (s )
12
+ for i in result :
13
+ print (i )
14
+
Original file line number Diff line number Diff line change
1
+ hex_num = input ()
2
+ dec_num = int (hex_num , 16 )
3
+ print (dec_num )
Original file line number Diff line number Diff line change
1
+ num = int (input ())
2
+
3
+ factors = []
4
+ divisor = 2
5
+
6
+ while divisor * divisor <= num :
7
+ if num % divisor == 0 :
8
+ factors .append (divisor )
9
+ num = num // divisor
10
+ else :
11
+ if divisor == 2 :
12
+ divisor = 3
13
+ else :
14
+ divisor += 2
15
+ if num > 1 :
16
+ factors .append (num )
17
+
18
+
19
+ print (" " .join (map (str , factors )))
Original file line number Diff line number Diff line change
1
+ num = int (input ())
2
+ d = {}
3
+ for i in range (num ):
4
+ aa , bb = input ().split ()
5
+ a , b = int (aa ), int (bb )
6
+ if a in d :
7
+ d [a ] = d [a ] + b
8
+ else :
9
+ d [a ] = b
10
+
11
+ ## 对字典排序的方式。
12
+ d = dict (sorted (d .items ()))
13
+ for i , j in d .items ():
14
+ print (i ,j )
You can’t perform that action at this time.
0 commit comments