Python Implements scissors stone cloth (three innings and two wins)

1 #-*-coding:utf-8-*-2 ImportRandom3 4 #Best of three5 deffinger_guess ():6Rule = {1:'Rock', 2:'Paper', 3:'Scissor'}7Win_way = [['Rock','Scissor'], ['Paper','Rock'], ['Scissor','Paper']]8Num_list = [1, 2, 3]9Count =0TenPerson_score =0

The inheritance of Python

Private VariablesThe "private" instance variable that cannot be accessed inside the object (including its subclasses) does not exist in Python. However, most Python code follows a convention: an underscore (for example, _spam The name of the

In the Python algorithm--bubble sort

#列表每两个相邻的数, if the front is bigger than the back one, then swap the two numbersThe # Shuffle () method randomly sorts all elements of a sequence.ImportRandomdefBubble_sort (LI): forIinchRange (Len (LI)-1):#I represent the trip forJinchRange (

python-Basics-List and tuple tuples

lists list To create a list:>>> week = ["Sun", "Mon", "Tue", "Wen", "Thu", "Fri", "Sat"]>>> Week[' Sun ', ' Mon ', ' Tue ', ' Wen ', ' Thu ', ' Fri ', ' Sat ']Basic operation: Index Slice Additional Delete Length Slice

Python install plug-in package considerations

Attention! Attention! Attention!It is strongly recommended to use PIP installation since Lib Library is installed:Reason:NU1: With EXE installation will appear a variety of unexpected surprises you!!!NU2: This kind of mistake is difficult to solve

Python Writing Login Interface

Idea One:#Coding:utf-8"""Login Interface:-Enter user name and password-show welcome message after successful authentication-lock three times after error"""ImportSys,osi=0 whileI : Name= Raw_input ('Please enter user name:') with open

Python input and output

eg : ex1.py#!/usr/bin/env python# _*_ coding = Utf-8 _*_Import GetpassName = Raw_input (' Please inputyour username: ')PWD = getpass.getpass (' inputyour password: ')print ' The name is: ', nameprint ' The password is: ', pwdExecution Result:[[Email

The conversion between Python XML and dictionary

def trans_xml_to_dict (XML): "" translates the XML format data returned by the payment interaction into a Python Dict object :p Aram xml: Raw XML Format data : return:dict Object "" " soup = BeautifulSoup (XML, features= ' xml ') XML =

The Association of Python functions and process-oriented programming

First: Co-processPreliminary understanding of the co-processdefEater ():Print('start to eat') whileTrue:food=yield Print('is eating food:%s'%Food )defproducer (): Dog=Eater () Next (dog)#The next wake-up process function #then the

Function-passing and reference in Python

In Python, the function integer, string, tuple are all values, the function does not change its value, the other will change its value in the functionFor example, send a list:#-*-ecoding:utf-8-*-def Fun (a): a[0]= "SSS"; Print a print ID (a) return;

Python's print line break

Output 9*9 multiplication table.For I in range (1, ten): Print for J in range (1, i+1): print "%d*%d=%d"% (i, J, I*j);650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8E/68/wKiom1i_oFewOu4MAAAcnspcfRw204.png-wh_500x0-wm_ 3-wmp_4-s_77511466

ubuntu16.04 Server Deployment Python environment method

One line of execution, you got a way. sudo apt updatesudo apt install gitsudo apt install vimsudo apt install tmuxsudo apt Install zshsh-c "$ (curl-fssl https: raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh) "Tmuxsudo apt-

Explanation of how the. mat file cannot be read correctly in Python

When importing a local. MAT data file in Python, it is always impossible to get the correct data. The problem code is as follows: From numpy import *import scipy.iomnist_train = ' D:\Machine Learning\tensorflow\softmax

A detailed description of the list and tuples in Python

Common operations: Index, Shard, add, multiply, check whether an element belongs to a member of a sequence, length, minimum, maximum Example: Numbers=[100,34,67]len (Numbers) #返回值为3max (numbers) #返回值为100min (numbers) #返回值为34 List : 1. List

Python Regular Expression Summary

Search (pattern,string,flags=0): Finds a match in a string Finddall (pattern,string,flags=0): Finds a match, returns a list of all matching parts Sub (pattern,repl,string,count=0,flags=0): Replaces the part of a string that matches a regular

Description of conditions, loops, etc. in Python

Gets any key-value pairs in the dictionary >>> x={' A ': 1, ' B ':2}>>> key,value=x.popitem () >>> key,value (' A ', 1) >>> del X[key] Traceback (most recent): File "", line 1, in del x[key]keyerror: ' A ' &G t;>> x{' B ': 2}>>> x[key]=value>>>

Pycharm developing Python Framework project generated file details

The global configuration of the project under directory Mydjangoproject is setttings.py, urls.py, and wsgi.py, respectively, 1, which setttings.py includes the system database configuration, application configuration and other configuration,2.

Full-text or single-line substitution method for file operations in Python

When Python modifies a file, using W mode empties/overwrites the original file. You can open it in Read (R) First, write it into memory, and then open it in write (w) mode. The taste in the replacement text is tasting Yesterday when I

Python-matplotlib Learning (1)

1 Import Matplotlib.pyplot as Plt 2 Import NumPy as NP 3 4 x=np.linspace ( -1,1,50)5 y=2*x+16plt.plot (x, y)7 Plt.show ()2: draw an image of Y=x*x1 Import Matplotlib.pyplot as Plt 2 Import NumPy as NP 3 4 x=np.linspace ( -1,1,50)5#y=2*x+16 y=x**27

Python Simple Small Program Exercises

1.99 multiplication Table# !/usr/bin/python for in range (1,10): is in range (i): + = 1 Print ("%d *%d =%-2d " % (i, j, i*j)), print"" 2. Daffodils#l = [] for in range (100,1000): if (a/100%10) **3 + (a/ 10%10) **3 + (a%

Total Pages: 4013 1 .... 3553 3554 3555 3556 3557 .... 4013 Go to: GO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.