1. Leap year (need to be optimized, can only be cycled once)year = Int (input ("Please enter the number of years:"))ifYear% 4: Print("not a leap year")#It can't be divisible by 4.Else: ifYear% 400: ifYear% 100: Print("Leap Year")#That can be divisible by 4, but not divisible by 100. Else: Print("not a leap year")#Divisible by 4 and divisible by 100, but not evenly divisible . Else: Print("Leap Year")#Divisible by 4 can be divisible by 400. E
Hello world!Print ("Hello Word")Simple Interactive (interactive, file-style) textbook P19The user enters two numbers and calculates and outputs the sum of two digits:N1=input ("1") n2=input ("2:")Print (Float (N1) +float (n2))The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula)A = float (input ('input triangle First side length:')) b= Float (Input ('input Triangle Second side length:')) C= Float (Input ('input triangle Third side length:'))#Ca
Print ("Hello world!! ")Name=input ("What is your name?\n") where=input ("where is you now?\n") Age=input ("How is old is you ? \ n")Print("your name is {}". Format (name))Print("You live in {}". Format (where)Print("You is {} years old". Format (age))A=input (" Please enter first number:") b=input (" Please enter a second number:") Sum1=float (a) +float (b)print(" sum of two numbers: {}". Format (SUM1)) a=float (Input ( " first side length: " )) b =float (Input ( " second side length: "
Hello world!
Print ('helloWorld')
Simple Interactive (interactive, file-style) textbook P19
Name=input ('name=')print('{} Shi ver handsome '. Format (name)
the user enters two numbers, calculates and outputs two digits of the sum:
a=input ( " a= " ) b =input ( " b= " ) s =float (a) +float (b) print ( " {} " . Format (s))
the user enters a triangular three-edged length and calculates the area of the tr
set Set # No mapping case, there is a mapping to a dictionary.Create a Collection1.set1=set ([1,2,3,3]) #重复直接剔除2.{} #set是无序的immutable set : Frozen frozen, frozen Frozenset1 num3 = Frozenset ([2-in-a- num3 = {3 -Num3.add (4 4 ErrorOpen' R ' opens the file as read-only' W ' opens the file as written, overwriting the existing file' x ' If the file already exists, open with this mode throws an exception' A ' opens in write mode, append write at end If file already exists' B ' to open files in b
Monte Carlo simulation# param numberdarts (int)# param Grapher (Turtle)# return approximation of Pi (float)def montepi (Numberdarts, Grapher):# Initialize Incirclecount counter (this was an accumulator)Incirclecount = 0# Loop for NumberdartsFor I in range (0, numberdarts):# Get random coordinate and position dartx = Random.random () * 2-1y = random.random () * 2-1# Draw Red dot and INCREMENT COUNTER if in circle, blue dot if notIf InCircle (x, y) = =
num = num-1 print (i)Another elementary turtle'stemp = input (' Please enter an integer: ') number = Int (temp) i = 1while number: print (i) i = i + 1 number = Number-19. (Copy the Little Turtle)temp = input (' Enter an integer: ') number = Int (temp) while number: i = number-1 while I: print (", end =") i = i -1 j = number while J: print (' * ', end = ') j = j-1 print () number = Number-11
Python implements the example code for drawing python Python.
This article mainly studies the example of the Python programming turtle and draws a colorful Python .. The details are as
to secret)Guess =0#Print () By default, a newline character is automatically added when the string is printed, and the end= "" parameter tells print () to use a space instead of a newline .#Well, the Little turtle feels creative you should try to use end= "JJ"? Print("guess which number the turtle is thinking now:", end=" ") while(Guess! = secret) and(Times >0): Temp=input () Guess=Int (temp) times= Times-
Topic:
Hello world!
Simple Interactive (interactive, file-style) textbook P19
The user enters two numbers, calculates and outputs the sum of two digits (try to implement it in one line of code).
The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula)
Enter a radius to calculate the area of the circle.
Draw a set of identical tangent circles
Draw a Pentagram
Draw an all-yellow pentagram
1: Output Hello wor
can only look at the data to see what kind of things in the class, inheritance, when the creation of the instance when the change occurred.*, The relationship between classes in Python can be vertical, using the inheritance mechanism to use all the properties and methods in the base class, but the parent class can not use the methods and properties of the subclass, such as fish and sharks, carp salmon, and so on; Of course, there can be horizontal re
Hello world!Print ("hello,world!")
Simple Interactive (interactive, file-style) textbook P19Name=input (" Please enter name:")print("{} students, please study!") ". Format (name))
The user enters two numbers and calculates and outputs the sum of two digits:N1=input ("1:") N2=input ("2:") print (float (N1) +float (n2))
The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula)
A=input ("A:") b=input ("B:") C=input ( "C:") s= (f
0. Note that this question is a bit different from the one in the last lesson, please go on the computer experiment or the answer.Old = [1, 2, 3, 4, 5]New = OldOld = [6]Print (new)What do you think will be printed if you do not operate on the computer?1,2,3,4,51. How do I change the ' Little Turtle ' below this list to ' small squid '?List1 = [1, [1, 2, [' Little Turtle ']], 3, 5, 8, 13, 18]list1[1][2]=[' s
First, the output Hello WorldPrint ("Hello Word")Second, summation operationA1 = input ("A1:"= input ("A2:"= float (A1) + float (A2) Print (" the first number {0} plus the second number {1} and is {2}". Format (a1,a2,sum))Three sides of the input triangle to seek the areaImport= input ("A1:"= input ("A2:" = input ("A3:"= (float (A1) +float (A2) +float (A3))/2D == d* (d-float (A1)) * (D-float (A2)) * (D-float (A3)) b=float (area) c= Math.sqrt (b)print(c)Four, the radius of the input circle, to
1. Output Hello word!Print ("Hello Word")2. Simple interactionName=input (" Enter name:")print("{} Students, learn python, promising!") " . Format (name))3, the user input two numbers, calculate and output two numbers of the sum:A=input ( " Please enter number a:") b=input (" Please enter number B:") c= Float (a) +float (b)print(" number {} plus number {} equals {}". Format (a,b,c))4, the user input triangle three-side length, and calculate the area
easily manipulate the URL# the URL can be constructed into a Request object first and passed into the urlopen #Request The meaning of existence is to facilitate the passing of some information at the time of the request, while urlopen does not8. because urlopen () is not supported for advanced features of some HTTP, we can use the Urllib.request.build_opener () method if we want to modify the header. Of course, you can also use Urllib.request.Request () to implement browser simulations. Focus
What language is 1.python?Python is an object-oriented, interpretive, high-level language that is part of a scripting language.What is 2.IDLE?Idle is the basic IDE for developing Python programs (integrated development environment) with basic IDE functionality and a good choice for non-commercial python development.Wha
Today we mainly learn the commonly used operators, such as arithmetic operators, comparison operators, logical operators, and so on, given that the courseware is doing too well (praise the Little Turtle ~ ~ ~ ~). I paste the picture directly (in fact, I am lazy)noun explanationStitchingThis is the first section of the study of a noun, because of their lazy, did not write, add here. Stitching, in fact, is to connect two strings together, not the other,
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.