Recently read some of Python's knowledge, here to record. 1. First is the installation, download the latest version 3.6 on the official website, the installation should pay attention to the following check the add to PATH, the installation will automatically write to the environment variables inside, if not checked, you can reinstall, or configure environment variables, here I will not say much.
Install and then command line input python-v appears on the command line indicating successful installation
2. Execution (2 ways)
Interaction Enter the Python command editor directly at the command line
-Script way into the corresponding directory, press shift+ right click, here to open the command window, execute python with a. py suffix file.
3. Notes
# !/usr/bin/python3 Single-line comment " " Multiline Comment-*-coding:utf-8-*-@Author: administrator@date: 2017-12-21 22:46:02@last Modified by: Administrator@last Modified time:2017-12-21 23:37:10" "
The rules of the 4 Sudoku game
" "Sudoku Game Rules (enter an odd number greater than 1) a 1 put in the middle of the first line b the next digit is placed in the upper-right corner of the previous number, if the row and column are out of range after the number is exceeded, the next digit is placed directly below the number. Without considering B ." "#Infinite Loop until the user enters exit, can play the game repeatedly whileTrue:Print('Please enter an odd number to start the game or exit') Content= Input ("Please enter:") if "Exit"==content:exit ()if notcontent.isdigit ():Print('the input is not a number') Continuelength=Int (content)ifLength% 2 = =0:Print('the number entered is not odd') Continuearr= [] forIinchRange (length): Arr.append ([]) forJinchRange (length): Arr[i].append ("Mouth") Row=0 Col= Length//2 forIinchRange (1, length*length+1): Arr[row][col]=I#Upper Right Cornerrow = Row-1Col= col + 1ifI% length = =0:col= Col-1Row= row + 2elifRow <0:row= Length-1elifCol >=Length:col=0 forIinchRange (length): forJinchRange (length):Print(Arr[i][j], end="\ t") Print("")#print (arr)
Python makes a Sudoku mini-game