Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://learnxinyminutes.com/docs/python3/
- https://www.youtube.com/watch?v=xfBWk4nw440
- Python is a programming language, difference between programming.
- Good points of python (not a lot of line, open-source, big community, multi-platform)
- 1. Variables (name should be meaningful, more maintainable - should be consistent)
- a. Number, string, bolean (True or False), array
- Temperature = [40,20,-10,25]
- b. Format properly
- c. Built-in function
- i. len() - certain are needed argument(s)
- ii. Print(f"({x})")
- d. [] are index [-1] [0:3] [0:] [:3]
- e. Specific function for number, string, bolean = NameVariable.upper() (not see in class :p)
- 2. Comment to explain your code to you but other ones
- 3. Basic math
- a. + - * / // % ** +=
- b. round, abs
- c. Import math (object)
- i. math.log() (google example)
- d. Operators > < == !=
- 4. If
- a. Every program you have to make a decision, that's why we have
- If temperature[1] > 35:
- Print('Evie will not be cold')
- Elif temperature[1] < 30:
- Print('Evie will be cold')
- b. Operators and or
- 5. For loop (we don't want to repeat a task for a number of time)
- for number in range(1,5):
- Print("Student", number)
- a. Step (1,2,10)
- 6. Combine for and if
- for i in range(1,5):
- If temperature[i] > 0:
- Print(f'At {temperature(i)}, it's not frozen')
- 7. Exercise 1: An artist want to make some ice statues of Trump in front of series of meteorological stations. He gives you a database with 10 stations (imagine there are thousands) and ask you a program that can deliver which station is below 0C but not below -10C. He also want the number of stations to know which quantity of materials he should bring.
- Count = 0
- For i in range (1,10):
- If -10<temperature(i)<0
- Count += 1
- Print(f"Station {i} is good")
- Print(f"we have {count) stations possible")
- 8. nested loop
- For x in range(1,5):
- For y in range(1,3):
- Print(f"({x},{y})")
- 9. Libraries (resources that you can use by using help on google)
- a. Example: plot with matplotlib
- 10. Function (make smaller code)
- Def frozen(database):
- …
- Frozen(temperature)
- Exercise 2: Find the prime numbers from 2 to 1000.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement