Tag Archives: coding

Pizza price calculation | 计算披萨价钱🍕

Many of us are still in coronavirus lockdown. We are very proud of all of you for staying healthy and safe.😀

In today’s google classroom, we ordered some pizza for lunch. 🍕  We made a Python program to calculate 👩‍💻 which pizza size gives us the best value.

Our goal: to find the lowest price per bite.  To get that, we divide cost by size.

def pizzaBitePrice(radius,price):
    area=radius**2*3.14
    unit_price = price/area
    return(unit_price)
# small pizza
pizzaBitePrice(7,12)
0.07799298063174313
# medium pizza
pizzaBitePrice(8,14.75)
0.06593351910828026
# large pizza
pizzaBitePrice(9,14.75)
0.057993237398757565

👍The conclusion is: the large size one gives us the best value with price of 5.7 cents (plus tax) per bite.

Welcome to our New Google Classroom!!😃

Hello everybody!😃 Welcome back to Magic Math Mandarin.  Since we are staying home because of covid-19, we brought our classes to google classroom so our students can keep on learning even during this pandemic👩‍🏫. Now we can all communicate with each other online💻. In this classroom we will be learning Chinese🈷, math➗, and programming👩‍💻. Our teachers will put new assignments everyday about each topic.  If you would also like to join our wonderful classrooms then here is the class code mtxl6j4

Remember to stay home and don’t get sick!😷 Please join our classroom today!👍💖

 

Loops in Swift Code | 循环 Xúnhuán

Hello everybody! Today in class we have learned 👩‍🏫 how to write loops 循环 (Xúnhuán) in Swift code 👩‍💻. We learned two kinds of loops ➰.

The first type of loop that we learned was a loop ➿ that repeats itself for a certain amount of times⏲. We learned 🏫 how to write this kind of loop in Swift code. Here’s an example.

for i in 1 … 4 {
moveForward()
turnRight()
moveForward()
turnLeft()
}

for i in 1 ... 4 {
moveForward()
turnRight()
moveForward()
turnLeft()
}

Next we learned another loop ⭕ that repeats itself until the condition is false🙅‍♀️. This loop is called a while loop. Here’s an example.

while thereIsACoin {
moveForward()
collectCoin()
}

while thereIsACoin {
moveForward()
collectCoin()
}

In a while loop the loop will go forward ⏩ and collect the coin 💰 nonstop until the is no more coins ☹ in front of the coin collecter to collect. This is what we have accoplished today in class 👩‍🎓👨‍🎓.

We will learn much more very soon. Goodbye!!😃😃

In the meantime, please do your homework, and use the Swift documentation (aka “instructions”).

Learning Swift | 学习Swift

This weekend we started our first lesson on Swift. Swift is the language used by Apple across its products.

The class first tried using XCode, which is Apple’s IDE for Swift. But not every child is familiar with the Mac. So we switched to a learn Swift phone app, which worked well. But the class really love Swift Playground.  It is like Scratch to them.  The difference is that: we are going to make an app in two months using Swift.

The kids enjoyed programming a lot!  They didn’t want to stop.

The only minor issue is that it only works on iPads.

Ipython Shell Keyboard shortcuts 键盘快捷键 (Kuàijié jiàn)

In this past weekend’s coding class we practice keyboard ⌨ shortcuts in the interactive Python shell (Ipython).

Since most of the students are learning typing ⌨, practicing these keyboard shortcuts actually help them learn typing by reinforcing memory of where the keys are.

The keyboard shortcuts allows you to minimize finger movements on the keyboard, which means you don’t even have to lift your hand ✋ for the “Backspace”, ‘Home’, ‘End’ or arrow keys (most of the time).    Spend 15 minutes per day practicing these.  Pretty soon, you will be a fast coder.

🚕Navigation

keystroke Action
Ctrl-a Move cursor to the beginning of the line
Ctrl-e Move cursor to the end of the line
Ctrl-b or the left arrow key Move cursor back one character
Ctrl-f or the right arrow key Move cursor forward one character

👦Text Entry

Keystroke Action
Backspace key Delete previous character in line
Ctrl-d Delete next character in line
Ctrl-k Cut text from cursor to end of line
Ctrl-u Cut text from beginning of line to cursor
Ctrl-y Yank (i.e. paste) text that was previously cut
Ctrl-t Transpose (i.e., switch) previous two characters

🐞Command History

Keystroke Action
Ctrl-p (or the up arrow key) Access previous command in history
Ctrl-n (or the down arrow key) Access next command in history
Ctrl-r Reverse-search through command history

🐳Miscellaneous

Keystroke Action
Ctrl-l Clear terminal screen
Ctrl-c Interrupt current Python command
Ctrl-d Exit IPython session

The shortcuts are referenced from  Python Data Science Handbook.   As its author Jake Vanderplas says, these shortcuts are not inherent in Ipython shell itself, but are based on GNU Readline library.

秋天好 | Autumn is good

Today in class we talked about autumn (qiū)(tiān) in this weekend’s Chinese lesson.

(qiū)(tiān)(dào)(qiū)(tiān)(hǎo)
(lán)(lán)(tiān)(kōng)白(bái)(yún)飘(piāo)
(bǎo)(bǎo)(tái)(tóu)(hā)(hā)(xiào)
magic math mandarin

Fall is here.  Fall is good.
Blue sky and white clouds.
The baby looks up and laughs.

Besides 中文, we are also working with other organizations to help children with computer programming 编程.

极客星晨少儿编程

API

Yes, this is still a Magic Math Mandarin blog–but to have tomorrow’s skills means a lot more than just knowing basic math.
API = plugin

This post is a quick note (updates are in progress).

Site that documents most APIs
https://www.programmableweb.com/
(more…)

Python getting help 帮助 (bāngzhù)

Before searching on the internet, please get help within the system.  It is much faster, and without distraction.

(more…)

error: Content is protected !!