程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python algorithm practice week1- fundamentals of programming

編輯:Python

0x00 machine language 、 Assembly language and high-level language ( With 2+3 For example )

  • machine language :01 Code 、CPU Cognitive language
    • Add operation :1001
    • Subtraction operation :1010
    • 2+3:1001 0010 0011
  • assembly language : Human readable mnemonics have been added to machine language
    • Add operation :ADD
    • Subtraction operation :SUB
    • 2+3:ADD 2,3
  • High-level language : A language close to natural language
    • sum = 2 + 3

0x01 How programming languages work

  • A compiled
    • Convert high-level language source code into object code ( machine language )
    • The program can run directly
    • The execution speed of the object code is fast
    • Representative language :C/C++
  • interpreted
    • Convert high-level language source code into object code one by one , Executing while converting
    • Each time you run a program, you need source code and an interpreter
    • It has good cross platform portability
    • Representative language :Java、Python

0x02 Program flow chart

Use a specified series of figures 、 Flow line and text explain the basic flow and control flow in the algorithm .

The basic elements of the flowchart include

  • A box representing the corresponding operation
  • Flow lines with arrows
  • Necessary text inside and outside the box

Sequential structure

  • The Fahrenheit temperature is described by a sequential structure F Convert to Celsius C The process of
  • The formula :C = 5/9*(F-32)
  • algorithm flow chart

Python Code implementation


Branching structure

  • Find the absolute value of a given number
  • algorithm flow chart

  • Python Language implementation
# Branching structure , Find the absolute value
R = int(input(' Please enter a number R:'))
if(R >= 0):
print('R The absolute value of is {}'.format(R))
else:
print('R The absolute value of is {}'.format(-R))

Loop structure

  • Input n Value , seek 1 To n Continuous addition and
  • algorithm flow chart

Python Language implementation


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved