# TODO: Write out the header for the quiz. # TODO: Shuffle the order of the states. # TODO: Loop through all 50 states, making a question for each. 因为这个程序会随机排序问题和答案,你需要导入random模块➊ 来使用它的函数。capitals变量➋ 包含一个字典,以美国各州为键,以它们的首都为值。
Take a quick Quiz to check it out Take a Quiz 5. What is the difference between slicing and indexing? Here are the differences between slicing and indexing: Slicing Indexing Slicing refers to creating a subset of an existing string like cutting out a portion of the sequence. Indexing refe...
Python Challenge home page, The most entertaining way to explore Python. Every puzzle can be solved by a bit of (python) programming.
It includes several quizzes, tests and programming assignments and projects to test & apply the learning in the best way. This course is taught by Jose Portilla in a very practical manner, first he gets you started with installation of Python on your computer, then he shows you live ...
import math class Circle: def __init__(self, radius): if radius < 0: raise ValueError("positive radius expected") self.radius = radius def area(self): assert self.radius >= 0, "positive radius expected" return math.pi * self.radius ** 2 The class’s initializer, .__init__(),...
self.driver.get(quiz_url)answer=self.driver.find_element_by_id("answer")answer.send_keys("123456")self.driver.find_element_by_id("submit").click()defcomplete_course(self):# 实现所有步骤,完成刷课self.login()course_list=self.get_course_list()forcourseincourse_list:self.select_course(course...
Courses & Paths Learning Paths Quizzes & Exercises Browse Topics Books Community Podcast Newsletter Community Chat Office Hours Workshops Learner Stories Company Team Sponsorships Careers Press Kit Merch Privacy Policy ⋅ Terms of Use ⋅ Security ⋅ Contact Happy Pythoning!©...
self.p2=p2print('quiz_8.PointError: Need two coordinates, point not created.')def__str__(self):ifp1:print('Point of x-coordinate',self.p1.x ,'and y-coordinate', self.p1.y)def__repr__(self):return#class quiz_8.PointError():#passclassTriangle(Point):def__init__(self, point_...
变量是在程序运行时存储数据的好方法,但是如果您希望数据在程序完成后仍然存在,您需要将其保存到一个文件中。你可以把一个文件的内容想象成一个单独的字符串值,大小可能是千兆字节。在本章中,您将学习如何使用 Python 来创建、读取和保存硬盘上的文件。
变量是在程序运行时存储数据的好方法,但是如果您希望数据在程序完成后仍然存在,您需要将其保存到一个文件中。你可以把一个文件的内容想象成一个单独的字符串值,大小可能是千兆字节。在本章中,您将学习如何使用 Python 来创建、读取和保存硬盘上的文件。