Python Language Design Program-Chapter One programming problem

Source: Internet
Author: User
Tags goto

Topic 1.1: Show "Welcome to Python"

Answer: Print (' Welcome to Python ')

Topic 1.2: Show "Welcome to Python" five times

Answer: Print ("Welcome to Python\n") * 5 #\n means line break, if not, it will be connected together.

Topic 1.3: Writing fun, where fun is composed of fun.

Answer: #注意, "n", "N" and "NN" lengths are inconsistent

Print ("F" *7, "" "* *," U "," "", "" U "," "" * *, "n" * *, "", "n" * *)
Print ("F" * *, "" "," "" "" "" "" "" "," "" "" "" "" "U", "" "" "", "" "" "" "," "" * * *)
Print ("F" *7, "" "*," U "," "", "" U "," "" "", "N" * *, "", "N" * *, "" * *, "n" * *)
Print ("F" * *, "" "," "" "", "" "," "", "" "", "" "" "," "" "" "" "" "" "" "" "" "" * * * * * *, "" * * *, "n"
Print ("F" * *, "" "," "", "" "," "", "" "" * *, "" * *, "" * *, "" * "* *," "" "" N "* *)

Topic 1.4: Programming shows the following table (similar matrix)

Answer: #二位数和两位数的长度不一样 to adjust the length of the space according to the length of the data

value= [1,2,3,4]
Print ("A", "* * *," a^2 "," "* * *," a^3 "," ")
Print ("1", "" * *, "1", "" "," 1 "," ")
Print ("3", "" * *, "9", "" "," 27 "," ")
Print ("4", "* * *," 16 "," "," 64 "," ")

Title: 1.5 The program shows the result of the following expression: (9.5*4.5-2.5*3)/(45.5-3.5)

Answer: Print ((9.5*4.5-2.5*3)/(45.5-3.5))

If you add double quotation marks, that is:

Print ("(9.5*4.5-2.5*3)/(45.5-3.5)")

That shows the formula (9.5*4.5-2.5*3)/(45.5-3.5)

Topic 1.6: Progression summation, programming shows 1+2+3+4+5+6+7+8+9 and

Answer: #for之后那一列 (may be a few columns) to indent

sum = 0

For I in range (10)

Sum+=i

Print (sum)

Topic 1.7: (approximate π) can be calculated using the following formula Π=4* (1-1/3+1/5-1/7+1/9-1/11+ ... ), programmed to show 1-1/3+1/5-1/7+1/9-1/11 and 1-1/3+1/5-1/7+1/9-1/11+1/13-1/15

Answer: #** means the second party

Program 1:

Pi = 0.0
For I in Range (1,6):
Pi + = ((( -1) * * (I+1))/(2*I-1))
Print (PI)

Program 2:

Pi = 0.0
For I in Range (1,8):
Pi + = ((( -1) * * (I+1))/(2*I-1))
Print (PI)

1.8

Displays the area and perimeter of the r=5.5 circle.

1.9;1.10;1.11 won't

1.12

Program: #求更加简单的分享

Import Turtle
Turtle.forward (100)

Turtle.right (90)
Turtle.forward (100)

Turtle.right (90)
Turtle.forward (200)

Turtle.right (90)
Turtle.forward (200)

Turtle.right (90)
Turtle.forward (200)

Turtle.right (90)
Turtle.forward (100)

Turtle.right (90)
Turtle.forward (200)


Turtle.left (90)
Turtle.forward (100)

Turtle.left (90)
Turtle.forward (100)

Turtle.left (90)
Turtle.forward (200)

Turtle.left (180)
Turtle.forward (100)

Program 2:

Import Turtle
Turtle.penup ()
Turtle.goto ( -50,0)
Turtle.pendown ()
Turtle.forward (100)
Turtle.penup ()
Turtle.goto (0,50)
Turtle.right (90)
Turtle.pendown ()
Turtle.forward (100)

Program 3: #注意转折处的角度

Import Turtle
Turtle.right (60)
Turtle.forward (100)
Turtle.right (120)
Turtle.forward (100)
Turtle.right (120)
Turtle.forward (100)

Program 4:

Import Turtle
Turtle.right (60)
Turtle.forward (100)
Turtle.right (120)
Turtle.forward (100)
Turtle.right (120)
Turtle.forward (200)
Turtle.left (120)
Turtle.forward (100)
Turtle.left (120)
Turtle.forward (100)

It's so boring, I'll paint it sometime

Python Language Design Program-Chapter One programming problem

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.