programming
from blocks to python
If you are interested in learning more Python ask your teacher about our lunchtime course!
A chatbot uses artificial intelligence (AI) software to simulate a conversation (or a chat) with a user in natural language.
They appear on messaging services, websites, mobile apps or through the telephone. Many chat bots are used for customer service. Simple bots are programmed to respond using a limited set of responses. More sophisticated chatbots use machine learning to develop their style and responses. |
Evri is a parcel-delivery company.
They use a chat bot to answer customer queries. If the customer can find their answer more quickly this way, the customer will be happy and the company has saved money on call centre staff. However, a chat bot is only as 'clever' as its programmer. Artificial Intelligence (AI) is becoming more and more sophisticated. The Evri chat bot is an example of a simple chat bot. |
Meet Alice.Alice stands for Artificial Linguistic Internet Computer Entity aka a chatbot. This is one of the earliest versions of a chatbot. Try chatting with it.
The original Alice didn't sound much like a human and often made mistakes. There are now more sophisticated bots. Woebot is a chatbot which won a Google Play app award in 2019. It's job is to try and connect with people and help with their mental well-being. Woebot has a programmed bank of responses. 'She/he' asks closed questions which can only get certain responses. Woebot is programmed to respond to the responses in a way that makes the user feel supported and as if they are talking to a human being. |
|
Program designBefore writing a program, it is first planned out using a flow chart.
Flow charts always begin and end with START and END oval shapes. The arrows show how data flows through the program The selection diamond shape is where we use if.....else in a program. This always has 2 arrows coming from it. Flow charts used standard shapes to help programmers understand the logic and data flow of a program. TASK Copy out the table of flowchart shapes on the right hand side. Use the title FLOWCHART SHAPES. |
Flowchart shapes |
Save the half-finished Scratch program on the right. Using your knowledge of Scratch and the flowchart above, re-order the code blocks to get the chat bot working. You should add at least one question of your own.
|
|
Selection in PythonOn the right you can see the if... else block in Scratch.
Notice how the code to be run is INSIDE the if block. In Python this is done using INDENTATION. If you write the code correctly, Python will automatically put in the indents. If you don't do it, you will get an INDENTATION error. To write this code in Python: answer= input("Do you need some help? ") if answer== "yes": answer = input("Enter your name: ") print ("Hello " + answer) answer = input("Enter your tracking number ") # code continues here else: print("Goodbye!") Sequencing & an intro to Python syntaxPython is a text-based programming language. It uses the same programming structures such as SELECTION and LOOPS that you have seen in block-based programming.
In this exercise you will drag and drop code into the correct order to solve the problem. At the same time, you will see the language Python uses. Click on the link on the right to drag and drop the Python code into the right order. |
When your teacher tells you, generate a report of your progress and screenshot this. Email the screenshot to your teacher.
|
Your teacher will tell you how to work with Python.
We use a Python editor called Thonny. You will find it on the school computers. You will need to open the text file here and copy and paste the code into a new Thonny file. This will get you started.
|
Title: Computational Thinking
Computational Thinking is solving problems in a logical way, especially so the solution can be executed by a computer. In your books, draw the envelope starting at the bottom left IN ONE SINGLE MOVEMENT AND WITHOUT GOING OVER ANY OTHER LINES. Now we will use Python Turtle to create this image. Turtle is a drawing module in Python. It works using the co-ordinates of the screen. The centre of the screen is x 0, y 0. See the image on the right to see how this works in practice. Below is some code to start you off. Copy and paste this into Thonny (find it in the Computer Science apps folder) ExtensionOn a new Python file (Thonny - File - New) - use turtle to draw your initials on screen.
FlagsThe sheet linked below will give you some extra code you can use.
Then try to create some of the flags on the right.
|
Additional turtle commandspen.right(90) # where 90 is an angle
pen.left(45) pen.forward(100) # where 100 is the number of 'steps' to move pen.backward(50) |