准备工作
- 实验会创建一个 Google Cloud 项目和一些资源,供您使用限定的一段时间
- 实验有时间限制,并且没有暂停功能。如果您中途结束实验,则必须重新开始。
- 在屏幕左上角,点击开始实验即可开始
Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional programming.
You will learn about the Python recursion in this lab. Python recursion is a programming technique where a function calls itself to solve a problem by breaking it down into smaller, similar sub-problems. This process continues until a base case is reached, at which point the function starts returning values, and these returned values are combined to obtain the final result. Recursion is often used to solve problems that can be divided into smaller, identical sub-tasks, making the code more elegant and concise in certain situations.
Please go through these directions. The Labs have a time limit and cannot be paused. The timer begins when you click the Start Lab button, shows how long Google Cloud resources will be made available to you.
After you click the Start Lab button, you will see an editor and terminal, where you will be performing further steps in the lab. It should looks like this:
You are going to finish a series of tasks related to Python programming.
task as shown below. You will need to use these files to complete the tasks in the lab.To complete this lab, you need:
Fill in the blanks to make the is_power_of function return whether the number is a power of the given base.
Click the files icon to access the pre-created file.
Open the pre-created task1.py file, by clicking on the file name.
Replace the (___) with the missing code into the above function.
Execute the code by entering the following command in the terminal.
The count_users function recursively counts the amount of users that belong to a group in the company system, by going through each of the members of a group and if one of them is a group, recursively calling the function and counting the members. The following code has a bug!
Click the files icon to access the pre-created file.
Open the pre-created task2.py file, by clicking on the file name.
Write the following code at the location marked by the #TODO comment in the task2.py file.
Identify the bug on the above code and fix the problem.
Execute the code by entering the following command in the terminal.
Implement the sum_positive_numbers function, as a recursive function that returns the sum of all positive numbers between the number n received and 1.
For example - when n is 3 it should return 1+2+3=6, and when n is 5 it should return 1+2+3+4+5=15.
Click the files icon to access the pre-created file.
Open the pre-created task3.py file, by clicking on the file name.
Complete the above python code that returns the expected output.
Execute the code by entering the following command in the terminal.
You have successfully completed the tasks related to Python Programming.
此内容目前不可用
一旦可用,我们会通过电子邮件告知您
太好了!
一旦可用,我们会通过电子邮件告知您
一次一个实验
确认结束所有现有实验并开始此实验