- The Python Workshop
- Andrew Bird Dr Lau Cher Han Mario Corchero Jiménez Graham Lee Corey Wade
- 332字
- 2021-06-11 12:51:25
Vital Python
In this chapter, we present vital Python concepts, the core elements that everyone needs to know before starting to code. You cover a breadth of topics with a focus on math, strings, conditionals, and loops. By the end of this chapter, you will have a strong foundation in Python, and you will be able to write significant Python programs as you continue with the rest of this book.
You will start with a very famous developer example; that is, Python as a calculator. In addition to the standard operations of addition, subtraction, multiplication, division, and exponentiation, you will learn integer division and the modulus operator. By using only basic Python, you can outperform most calculators on the market.
Next, you'll learn about variables. Python is dynamically typed, meaning that variable types are unknown before the code runs. Python variables do not require special initialization. Our first variables will be integers, floats, and strings. You will identify and convert between types.
Next, in order to work with strings, you will utilize string methods, in addition to indexing, slicing, and string concatenation. You'll also use built-in functions such as print() and input() to communicate with the user.
Moving ahead, you'll encounter Booleans, true or false Python types, that precede conditionals, statements with if clauses that lead to branching. Booleans and conditionals allow us to write more complex programs by taking a greater number of possibilities into account.
Finally, you close the chapter with loops that allows us to repeat operations. In particular, we apply while loops and for loops, utilizing break and continue.
For true beginners, this introductory chapter will get you up to speed with basic programming concepts. If you are new to Python, you will see why the Python language is so clear, powerful, and valuable. By the end of this chapter, you will be comfortable running Python basics on their own, and you will be prepared to tackle more of the advanced concepts ahead.
Let's start coding in Python.
- 大數(shù)據(jù)技術(shù)與應(yīng)用基礎(chǔ)
- Drupal 7 Multilingual Sites
- AWS:Security Best Practices on AWS
- 機(jī)器學(xué)習(xí)與大數(shù)據(jù)技術(shù)
- Zabbix Network Monitoring(Second Edition)
- 群體智能與數(shù)據(jù)挖掘
- Hands-On Cybersecurity with Blockchain
- 網(wǎng)絡(luò)布線與小型局域網(wǎng)搭建
- 中國戰(zhàn)略性新興產(chǎn)業(yè)研究與發(fā)展·增材制造
- Photoshop CS4數(shù)碼攝影處理50例
- Visual Basic項(xiàng)目開發(fā)案例精粹
- Hands-On Business Intelligence with Qlik Sense
- Hands-On DevOps
- 開放自動化系統(tǒng)應(yīng)用與實(shí)戰(zhàn):基于標(biāo)準(zhǔn)建模語言IEC 61499
- 歐姆龍PLC應(yīng)用系統(tǒng)設(shè)計(jì)實(shí)例精解