Learning how to compile a simple multiplication operation in python

Source: Internet
Author: User
This article mainly introduces how to compile simple multiplication operations in the first quarter of python. For more information, see the following code:

#! /Usr/bin/python // handler # filename jiafa. py // file name import sys import random running = True // define running while running: a = random. randint () // defines a random number ranging from 0 to 15. B = random. randint () // defines the random number print ,'*', B // output question he = a * B gauess = int (raw_input ('Please answer: ') // defines the user input value if gauess = he: // determine whether the user input is equal to the actual value print "right! Continue? Y/N "// if the values are equal, the output is correct and you are asked whether to continue fd = raw_input (" please Enter :") // obtain the keyboard input value str1 = 'y' zhi = cmp (fd, str1) if zhi = 0: // determine whether the keyboard input value is Y, if yes, execute and exit. If not, return to while again and output the new question print "this is over" sys. exit () elif gauess

 

  

If the test is performed, pay attention to the format

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.