这个函数的基本结构完成以后,你可以通过另一个函数调用执行,也可以直接从Python提示符执行。 如下实例调用了上边代码块的my_fun()函数: def my_fun( par_num ): ""判断传入参数的2倍是否大于50,如大于显示√,否则显示X" par_num = par_num * 2 if par_num > 50: display.show(Image.YES)
7.1 Python中的随机数 随机选择 有时候你想让事情变得无序一点,让程序看似有自己的想法,这时候你需要生成一些随机的东西,MicroPython提供了一个对象用来生成随机数,他就是random可以轻松为你的代码引入随机和混乱。 random对象可以从提供的列表字符串元组等符合数据类型中,随机选择一个元素作为参数返回,例如:...
模块让你能够有逻辑地组织你的 Python 代码段,把相关的代码分配到一个模块里能让你的代码更好用,更易懂。 模块定义好后,我们可以使用 import 语句来引入模块,语法如下: fromimportmodule1[,module2[,...moduleN] 这行代码的意思是:我需要获得MicroPython的所有东西,我们需要“from(来自)”“microbit(模块)”的...
For this tutorial I’m using version 1.7.0 of uPython for the Micro:bit board. The code We will start our code by importing the uart object and the sleep function, both from the microbit module. from microbit import uart, sleep Then we will initialize the serial interface, using as Rx...
Micro:bit提供网页在线工具和可以安装在本地的离线工具。 在线工具 Micro:bit官方链接地址:http://python.microbit.org/v/1 Micro:bit官方在线代码编写平台,使用常用浏览器直接打开上述网址即可使用。 离线平台 Micro:bit官方也推出了一个离线的编译工具MU,方便在没有网络连接的时候也可以进行创意和教学。
micro:bit uPython: Pausing the program execution In this short tutorial we will check how we can pause the execution of a program on the Micro:bit, running MicroPython. Introduction In this short tutorial we will check how we can pause the execution of a program on the Micro:bit, running...
因此英语水平有限的人士也可以根据图片完成练习。MakeCode官网上的教程虽然以英文呈现,但已有热心网友将其翻译成中文,为学习者提供了极大的便利。同时,你也可以参考https://micropython.nxez.com/microbit-tutorial/Micro_bit_Board/等网站上的教程进行练习。充分利用这些丰富的网络资源,你定能自学成才。
相关文档在这儿: micro:bit Tutorial。 这个插件一直在稳定使用,CodeLab 在做活动时使用它;一些公司在教育机构里使用它;有些学校在课堂上使用它。 Think Bigger 前头方案尽管兼容性、可扩展性和稳定性足够好,但依然有其局限性,我自己最不满意的是它并未与 micro:bit 生态做深度连接。只是通过开发者构建固件来建立...
In this tutorial, I am going to show you how to code BBC micro: bit using MicroPython and how to display your name and other basic symbols on your micro: bit, by writing Python code manually. So, let's start. What is BBC micro: bit?
This tutorial will get you started using the gator:UV with the micro:bit platform. Wireless Remote Weather Station with micro:bit Monitor the weather without being exposed to it through wireless communication between two micro:bits using the radio blocks! This is useful if your weather station...