Hello World

Python, of course, is the hottest, hottest, and most widely used programming language of the moment. Tycoon Pan Shiyi also said that his 56th birthday gift was to learn Python programming from scratch. Indeed, Python is widely used in all walks of life. Yesterday, I was fortunate to learn that a security guard is also learning Python. Really, it’s never too late to learn Python, and the time to do it is now! As a well-known saying in the Python world goes: the best time to learn Python was ten years ago and now!

I think most children’s shoes start with the famous “Hello World”! I am not. In the spirit that the nation is the world and the future, my first Line of Python code is — Hello world! In the end, as I had hoped, Python was successfully applied to work scenarios, resulting in increased productivity and a slight increase in salary. Who says a career changer can’t do data analysis? You can do analysis, you can model. Follow my article and share go, certainly can wish, successful career change.

Today, here is a summary of Python code programming, to share with you:

Q0: A = 128,b = 512 variable value exchange with one line of code? Q1: Find the maximum value x = 1024,y = 256 in one line of code? Q2: convert lists [[1,2],[3,4],[5,6]] to [1,2,3,4,5,6] with one line of code? Q3: Implement a string in one line of code'123456789'Convert ['123'.'456'.'789']? Q4: a one-line implementation to convert the list [1,2,3,4,5] to ['1'.'2'.'3'.'4'.'5']? Q5: use a code implementation to list the [[1, 2], [3, 4], [5, 6]] into [,3,5 [1], [2 minus 2]]? Q6: convert lists [[1,2,3],[4,5,6]] to [1,2,3,4,5,6] in one line of code? Q7: Find the minimum q = 10086,w = 10010,e = 10000 in one line of code? Q8: Generate a list of even numbers between 1 and 100 in one line of code. Q9: Generate a list of odd numbers between 1 and 100 in one line of code?Copy the code


I am the answer

Are you sure you thought about it?

Did you really think about it?

Think about it?

Q0: A = 128,b = 512 variable value exchange with one line of code? >>> a,b = 128,512>>> a128>>> b512>>> a,b = b,a>>> a512>>> b128Q1: find x = 1024,y = 256 Max with one line of code? >>> x,y = 1024,256>>> xif x>=y elseY1024Q2: use a code implementation to list the [[1, 2], [3, 4], [5, 6]] to [6]? >>> q2 = [1,2],[3,4],[5,6]]>>> [Ifor l in q2 for i inL][1, 2, 3, 4, 5, 6]Q3: Implement the string in one line of code'123456789'Convert ['123'.'456'.'789']? >>>'123456789'.split(', ') ['123'.'456'.'789']Q4: a one-line implementation to convert the list [1,2,3,4,5] to ['1'.'2'.'3'.'4'.'5']? > > > list (map (STR) [1, 2, 3, 4, 5]) ['1'.'2'.'3'.'4'.'5'List] Q5: use a code implementation to [[1, 2], [3, 4], [5, 6]] into [,3,5 [1], [2 minus 2]]? >>> [list(i)for i inZip (* [[1, 2], [3, 4], [5, 6]]]] [[1, 3, 5], [2, 4, 6]] of Q6: use a code list [[1, 2, 3], [4 and 6]] to [6]? > > > the sum ([[1, 2, 3], [4 and 6]], []) [1, 2, 3, 4, 5, 6] Q7: use a code implementation to find q = 10086, w = 10010, 10000 minimum e =? >>> q,w,e = 10086,10010,10000>>> qif q<w and q<e else w if w<e elseE10000Q8: Generate a list of even numbers between 1 and 100 in one line of code? >>> [ifor i inRange (1101)ifi%2 == 0][2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100] >>> list(filter(lambda x:x%2,[ifor i inRange (1,101)]) [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 93, 95, 97, 99]Copy the code

Well, this is the first time to share this issue, and more Python tutorials and learning methods will continue to update you!