Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 PYTHON


  The tic-tac-toe game with Python

In this tutorial, we will show how to build a tic-tac-toe game with Python. We will use functions,arrays,if statements,while statements, for loops and error handling etc.First, we need to create two functions, the first function will display the borad of the game:def print_board(): for i in range(0,3): for j in range(0,3): print map[2-i][j], if j != 2: print "|", print ""Here we used two for loops to loop through the map, this map is a two dimensional array which contains the location information.The board looks like: | | | | |...

24,954 1       PYTHON TIC-TAC-TOE


  Problem and Solution for Installing wxPython on Ubuntu 20.04

When we try to install wxPython lib on Ubuntu system to do software GUI development,most of time we may meet some installation and lib dependency problems. For the latest Ubuntu version, the problems still happen. Below are some common problems which happened frequently and their solution:---------------------------------------------------------------------------------------------------------------Problem [1]: Install wxPython on Ubuntu 20.04 fail because of dependency package Gtk is not installed.Error Message:No package 'gtk+-3.0' found Package gthread-2.0 was not found in the pkg-config sea...

23,078 7       UBUNTU 20.04 WXPYTHON PYTHON


  Build route graph of Hurricane Sandy

Hurricane Sandy swept US east side and landed in New York, it killed 113 persons and incurred 50 billion US dollars economic loss. Sandy is also considered as the most expensive hurricane. We will now use matplotlib and basemap libraries in Python to build a route graph of Sandy.Below is the animated GIF.Shadow is added in the graph to show the time at night, we can see from the graph that Sandy stayed a while in Panama after emerging, then it went through Cuba and became Hurricane-2. Later Sandy moved along US east coast and then turned to west suddenly, headed directly to New York and landed...

14,036 0       PYTHON HURRICANE SANDY ROUTE GRAPH


  Learning Python as your first programming language

Python is a widely used general-purpose, high-level programming language Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C. Python now becomes more and more popular and is now being used the first teaching language in some universities. Why would you like to learn Python as your first programming language? Below are the reasons.Python is a high-level language with dynamic typing. It means it won't bother you with things like pointers and memory management, and provides yo...

12,286 0       ADVANTAGE PYTHON


  Ruby is beautiful (but I’m moving to Python)

The Ruby language is beautiful. And I think it deserves to break free from the Web. I think the future of Ruby is firmly stuck in Web development, though, so I’m going to invest in a new language for data analysis, at least for now. This is a look at the fantastic language I came to from Java and a look at a possible candidate. (Update: I’ve since written a followup.)Java to RubySix years ago, I added Ruby to my technical arsenal. I learned C++ and Java in high school, and I planned to use them for data analysis in college—mainly for research kung fu. But when I disco...

12,219 0       JAVA COMPARISON RUBY ADVANTAGE PYTHON RUBY VS PYTHON


  Python basics summary

Python is recommended by many people as the first language to be learned now. Even in some universities, it is the primary language to be taught to CS/CE students. To master this languages, we should understand some basics of it. Here we summarize some basics about this language.These basics include : string replacement with regular expression, traverse a directory, sort a list, remove duplication, dictionary ordering, dictionary, list, string conversion, date object manipulation, command line parameter parsing(getopt), formatted output, Call system commands or scripts with Python, Python file...

11,120 0       SUMMARY PYTHON


  Python Patterns - An Optimization Anecdote

The other day, a friend asked me a seemingly simple question: what's the best way to convert a list of integers into a string, presuming that the integers are ASCII values. For instance, the list [97, 98, 99] should be converted to the string 'abc'. Let's assume we want to write a function to do this.The first version I came up with was totally straightforward: def f1(list): string = "" for item in list: string = string + chr(item) return stringThat can't be the fastest way to do it, said my friend. How about this one: def f2(list): return reduce...

10,638 0       PYTHON OPTIMIZATION ANECDOTE LOOPUP ASCII


  Where Have You Installed Your Python Packages?

PrefaceI am writing this article because I recently noticed in the Python community that there are several frequently asked questions:Why does running the command after installing pip result in a "executable not found" error?Why does importing a module result in a "ModuleNotFound" error?Why can I run my code in PyCharm, but it doesn't work in the command prompt?Rather than just providing solutions, it is better to teach people how to fish. To address these types of issues, you need to understand how Python locates packages. I hope that after reading this article, you will find it helpful.How P...

9,860 1       PYTHON PATH PATH_PREFIX PACKAGE LOCATION