{%hackmd theme-dark %} Computer Science Club (1) === python --- ## Join Our Facebook Chatroom - You can ask if you have any question, and I will answer them as soon as possible and help you solve your problem. --- ## About This Club - We are not here to play games. - We are going to learn programming. --- ## What We Are Going to do - Learning ML(Machine Learning) ---- ## But Before Those - We have to learning basics of python --- Now, you have to konw something about ## PYTHON ---- - Interpreted language - IDE: IDLE, Anaconda - online IDE: google colab --- ## Usage 1. Enter [google colab](https://colab.research.google.com/) 2. Log in with FDmail account: `s`+`學年度`+`學號末3碼`+ `@gm.fdhs.tyc.edu.tw` password: `fd`+`身分證末4碼`+`生日4碼` 3. Click `新增筆記本` 4. Start coding ---- ## Sample Code :::spoiler `sample 1` ```python= print('hello, world') ``` ::: :::spoiler `sample 2` ```python= s = input() print(s) ``` ::: What is the result after execution? ---- ## Now, let's learn coding --- ## Study Notes: [[PYTHON] 基礎語法篇](https://happylearningcoding.blogspot.com/2020/07/python.html) [[PYTHON] DICT 篇](https://happylearningcoding.blogspot.com/2020/07/python-dict.html) [[PYTHON] LIST 篇](https://happylearningcoding.blogspot.com/2020/07/python-list.html) [[PYTHON] STRING 篇](https://happylearningcoding.blogspot.com/2020/07/python-string.html) --- ## Let's Know What We Can do For Now ---- ## Judge Whether a Year is a Leap Year or Not :::spoiler code ```python= year = int(input()) if year % 400 == 0 or year % 4 == 0 and year % 100 != 0: print('a leap year') else: print('a normal year') ``` ::: ---- ## Judge Whether a Number is a Prime or Not :::spoiler code ```python= num = int(input()) isprime = True for i in range(2, int(num ** 0.5)): if num % i == 0: isprime = False break print(isprime) ``` ::: ---- ## Calculation e.g. `sqrt(abs(log(ln(tan(cos(sin((1+2-3*4/5!))))))))^e*pi` :::spoiler code ```python= from math import * def main(): while 1: try: s = input().replace('^','**') s = s.replace('log','log10') s = s.replace('ln','log') ans, i, t = '', len(s) - 1, 0 while i >= 0: if s[i] == '!': if s[i - 1].isdigit(): t, i = i, i - 1 while s[i].isdigit(): i -= 1 tmp = s[i + 1: t] s = s[:i + 1] + 'factorial(' + tmp + ')' + s[t + 1:] else: t, right, i = i, 1, i - 2 while right: if s[i] == ')': right += 1 if s[i] == '(': right -= 1 i -= 1 tmp = s[i + 1: t] s = s[:i + 1] + 'factorital(' + tmp + ')' + s[t + 1:] i -= 1 ans = eval(s) print('{:.5f}'.format(ans)) except: break if __name__ == '__main__': main() ``` ::: --- ## What Are We Going to do Next Time - Learn `"ML(machine learning)."` - Directly use the code to implement. **So, what should we do after class to enhance our coding ability?** --- ## Somewhere You Can Practice After Class Online Judge: 1. [dandanjudge](http://dandanjudge.fdhs.tyc.edu.tw/) 2. [zerojudge](https://zerojudge.tw/) --- ## Thanks This presentation is public. You can visit hackmd.io/@gtcoding at any time to learn programming. --- ## The Only Thing You Can do Now - Practice on online judge [dandanjudge](http://dandanjudge.fdhs.tyc.edu.tw/) or [zerojudge](https://zerojudge.tw/)
{"metaMigratedAt":"2023-06-15T12:54:24.153Z","metaMigratedFrom":"YAML","title":"Computer Science Club (1)","breaks":true,"contributors":"[{\"id\":\"6587fbcb-5744-488e-ac7d-8d93a89a11f4\",\"add\":4519,\"del\":744},{\"id\":\"7f88bde8-f34b-4250-aca4-5f75a1c80ff9\",\"add\":5,\"del\":0},{\"id\":\"f50fb215-b7ff-4083-ad52-44c744b7d32f\",\"add\":1,\"del\":0}]"}
    472 views