Starting Python

Background 背景

Equip yourself 安裝

  1. Python
    Of course we need python to execute any .py file
  2. Editor (Integrated Developer Environment)
    Any place can let you type
  3. Packages
    Some written programs can save you a lot effort

Start programming 開始撰寫

Jupyter Notebook and Spyder
print('Hello World')

The first project

Problem 1

Multiples of 3 and 5

Solution

#To have number of multiples of each number
a_3 = 999//3 #number of multiples of 3 under 1000
a_5 = 999//5 #number of multiples of 5 under 1000
a_15 = 999//15 #number of multiples of 15 under 1000
#taking the sum of 3 and 5 and subtract the common sum which is multiples of 15final = 3*((1+a_3)*a_3/2)+5*((1+a_5)*a_5/2)-15*((1+a_15)*a_15/2)print(final)

--

--

--

Graduated master in astronomy. Wanna code a better world. 天文所畢業,致力使世界更好。

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

DevOps-ifying your Infrastructure Code using GitHub Actions and Docker

Quickly generate full stack app with Full Stack FastAPI and PostgreSQL

I finally used method-swizzling

Adding Fog to the HDRP Pipeline in Unity 2020

Reversing with IDA: Cross-references

Block chain Using Java’s Web3j and Ethereum Part II: Create or Open an account

Junior Developers are Problem Solvers. Languages are Tools.

Docker Get Started

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lin Han Tang

Lin Han Tang

Graduated master in astronomy. Wanna code a better world. 天文所畢業,致力使世界更好。

More from Medium

WHAT IS THE USE OF PYTHON IN WEB DEVELOPMENT

Learning Python -Datatypes(Part 4)

How To Make Looping in Python

Where does Python “go”?