- AI Crash Course
- Hadelin de Ponteves
- 192字
- 2021-03-26 16:22:43
Displaying text
We'll begin with the most popular way of introducing any programming language; you'll learn how to display some text in the Python console. The console is a tool that's part of every Python editor, which shows the information we want or displays any errors that occurred (let's hope not to get any!).
The easiest way to show something in our console is to use the print()
method, just like this:
# Displaying text
print('Hello world!')
The text above print
, starting with #
, is called a comment. Comments are excluded when executing code and are only visible to you.
After running this short code in Google Colab, you'll see this displayed:
Hello world!
In conclusion, just put what you want to display into the brackets of the print
method – text surrounded by quotes, as in this example, or variables.
If you're curious about what variables are, that's great – you'll learn about them after this exercise.
Exercise
Using only one print()
method, try to display two or more lines.
Hint: Try using the \n
symbol.
The solution is provided in the Chapter 03/Displaying Text/homework.py
file on the GitHub page.
- SQL入門經典(第5版)
- 使用GitOps實現Kubernetes的持續部署:模式、流程及工具
- App+軟件+游戲+網站界面設計教程
- WS-BPEL 2.0 Beginner's Guide
- 智能數據分析:入門、實戰與平臺構建
- Starling Game Development Essentials
- 重復數據刪除技術:面向大數據管理的縮減技術
- 區塊鏈+:落地場景與應用實戰
- 企業大數據處理:Spark、Druid、Flume與Kafka應用實踐
- 算法設計與分析
- MySQL性能調優與架構設計
- Configuration Management with Chef-Solo
- Hands-On Java Deep Learning for Computer Vision
- Nagios Core Administrators Cookbook
- 大數據用戶行為畫像分析實操指南