CHAPTER_1_BEGINNINGS

一、规则3:最好的提示编程能力和解决问题能力的方式就是练习。(Rule 3: The best way to improve your programming and problem skills is to practice!.)

# Code Listing 1.1
# Calculate the area and circumference of a circle from its radius.
# Step 1: Prompt for a radius.
# Step 2: Apply the area formula.
# Step 3: Print out the results.
import math
radius_str = input("Enter the radius of your circle: ")
radius_int = int(radius_str)
circumference = 2 * math.pi * radius_int
area = math.pi * (radius_int ** 2)
print ("The cirumference is:",circumference, "and the area is:",area)

上一篇:CS:APP Chapter 3 程序的机器级表示-读书笔记


下一篇:substitute Chapter to Ch and chapter to ch in springboot idea project