Elegant python and elegant python
Based on the question, we cannot use keywords such as if/else/for/while.
-------------- Thinking ------------
Ideas:
1. Implement loops using recursion
2. How can we judge the recursive termination condition without the use of if? The answer is the dictionary, where not n is used to convert the number n to bool.
Code:
def sum_(n): return n + { True:lambda:sum_(n-1), False:lambda:0 }[not not n]()print sum_(100)
What is the current prospect of python?
Nowadays, many companies require that, in addition to a static language, they can master a scripting language such as perl, shell, and python.
Because you often need to use the scripting language to develop some small programs at work, the reason is that the syntax of the script language is simple, so that programmers can quickly solve the problem.
Python can be used for development and management scripts.
Douban.com is developed in python.
As for the python salary, it is hard to say it depends on your company's situation.
Python for Loop
Wrong reading of the question. I will try again
============
Run python 3.2,> 3.0
Import functools
Def occurrences (text1, text2 ):
# Use a dictionary to count the number of text1 contained in text2.
S_items = dict (map (lambda I :( I [0], text2.count (I [0]), dict (zip (text1, [0] * len (text1 ))). items ()))
Print (s_items) # The output process is your "1 'E', 3 'l', 2 'o', and 1 'D'". This line can be deleted.
# Sum of combined output statistics
Return functools. reduce (lambda x, y: x + y, s_items.values ())
Print (occurrences ('fooed', 'Hello World '))
============================
Output
{'F': 0, 'E': 1, 'D': 1, 'O': 2, 'L': 3}
7