Merge remote-tracking branch 'youngjin/master'

This commit is contained in:
Nico Schottelius 2020-05-22 17:12:04 +02:00
commit de2f6d0749
22 changed files with 426 additions and 176 deletions

8
.gitignore vendored
View file

@ -1,4 +1,4 @@
/youngjin.han/dot-cdist/type/__my_computer/manifest~ manifest~
/youngjin.han/cdist.org~ *.py~
/youngjin.han/dot-cdist/type/__colourful_file/file/colourful~ *.org~
/youngjin.han/dot-cdist/type/__colourful_file/manifest~ *.org#

View file

@ -8,7 +8,7 @@ case "$__target_host" in
# __colourful_file --colour yellow --colour blue --colour red --colour green # __colourful_file --colour yellow --colour blue --colour red --colour green
# __my_dotfiles # __my_dotfiles
# __my_nginx_site $__target_host # __my_nginx_site $__target_host
# __all_in_one $__target_host --with-x --extra-packages tree --extra-packages htop # __all_in_one --with-x --extra-packages tree --extra-packages htop
__my_firewall --file /etc/my-nftables __my_firewall --file /etc/my-nftables
;; ;;
jafo.laptop) jafo.laptop)

View file

@ -1,12 +1,10 @@
#!/bin/sh -e #!/bin/sh -e
os="$(cat "$__global/explorer/os")" os="$(cat "$__global/explorer/os")"
default_package_name="socat sipalc sudo" default_package_name="socat sipcalc sudo"
if [ -f "$__object/parameter/with-x" ]; then if [ -f "$__object/parameter/with-x" ]; then
with_x="$(cat "$__object/parameter/with-x")" with_x="$(cat "$__object/parameter/with-x")"
else
with_x="$__object_id"
fi fi
case "$os" in case "$os" in
@ -14,7 +12,7 @@ case "$os" in
name_netcat="netcat-openbsd" name_netcat="netcat-openbsd"
name_wireshark="tshark" name_wireshark="tshark"
;; ;;
debian) debian|devuan)
name_netcat="netcat" name_netcat="netcat"
name_wireshark="tshark" name_wireshark="tshark"
;; ;;
@ -33,12 +31,12 @@ all_package_name="$default_package_name $name_netcat $name_wireshark"
__package_update_index __package_update_index
for package in $all_package_name; for package in $all_package_name; do
do require="__apt_update_index" __package $package --state=present require="__package_update_index" __package $package --state=present
done done
if [ -f "$__object/parameter/extra-packages" ]; then if [ -f "$__object/parameter/extra-packages" ]; then
for package in $(cat "$__object/parameter/extra-packages"); do for package in $(cat "$__object/parameter/extra-packages"); do
require="__apt_update_index" __package $package --state=present require="__package_update_index" __package $package --state=present
done done
fi fi

View file

@ -1,3 +1,35 @@
* 2020-05-20
*** Python #2:
**** DONE Lecture content
CLOSED: [2020-05-20 수 22:47]
- Read thoroughly & do exercises 8 to 14
- Focus on understanding
- You don't have to type everything
- But you should ensure you understand everything
- Commit all source code to ~/ungleich-learning-circle/USERNAME/python-the-hard-way
- Write down notes / what you learned in the *python.org* file
- Notify your fellow students when you solved something
- "I just solved exercise 4!"
**** Lecture material
- Available on https://cloud.ungleich.ch/s/435FyfrQyEq6oF3
* 2020-05-15
*** Python #1:
**** Lecture notes
- Ensure that you have python3 (at least 3.6) installed
- Use emacs for editing source files
- Commit all source code to ~/ungleich-learning-circle/USERNAME/python-the-hard-way
**** DONE Lecture content
CLOSED: [2020-05-19 화 23:47]
- Read thoroughly & do exercise 0 to 7
- Commit your source code in git
- Commit every time you have a task done
- Make a new commit in git each time you finish (part of) a task
- Do all exercises
- Notify your fellow students when you solved something
- Ask help to other students when you are stuck (but try to solve
on your own before)
**** Lecture material
- Available on https://cloud.ungleich.ch/s/435FyfrQyEq6oF3
* 2020-05-15 * 2020-05-15
*** cdist #6: Glueing it together *** cdist #6: Glueing it together
**** Lecture content **** Lecture content
@ -20,7 +52,7 @@
Alpine/Debian/Fedora, output an error message and abort the Alpine/Debian/Fedora, output an error message and abort the
manifest with exit code 1 manifest with exit code 1
- Additionally install all packages specified by the *--extra-packages* parameter - Additionally install all packages specified by the *--extra-packages* parameter
***** Steps 2: *__firewall* (1.25h) ***** TODO Steps 2: *__firewall* (1.25h)
- Create a new type *__my_firewall* - Create a new type *__my_firewall*
- Add a *type explorer* to find out whether nft is present on - Add a *type explorer* to find out whether nft is present on
the target system the target system
@ -33,7 +65,7 @@
ruleset by generating code in *gencode-remote* ruleset by generating code in *gencode-remote*
- If the filename specified by the *file* parameter is *-* (the - If the filename specified by the *file* parameter is *-* (the
minus sign), then the type should read from *stdin* minus sign), then the type should read from *stdin*
***** Step 3: manifest (0.5h) ***** TODO Step 3: manifest (0.5h)
- Create a new manifest in the folder that contains the initial manifest - Create a new manifest in the folder that contains the initial manifest
- Name the new manifest *firewall* - Name the new manifest *firewall*
- Source the *firewall* manifest in the *initial* manifest - Source the *firewall* manifest in the *initial* manifest
@ -127,201 +159,146 @@
***** DONE As usual commit all changes to your ungleich-learning-circle repo ***** DONE As usual commit all changes to your ungleich-learning-circle repo
CLOSED: [2020-05-15 금 21:07] CLOSED: [2020-05-15 금 21:07]
* 2020-05-06 * 2020-05-06
** cdist #2: Your first cdist type *** cdist #2: Your first cdist type
**** Lecture content **** Lecture content
***** Objective ***** Objective
****** Begin to understand how cdist types function ****** Begin to understand how cdist types function
***** Steps ***** Steps
****** DONE Create a new type named `__my_computer` ****** Create a new type named `__my_computer`
CLOSED: [2020-05-06 수 22:53] - Mark the type as a singleton type
******* DONE Mark the type as a singleton type - Create a `manifest` file in it
CLOSED: [2020-05-06 수 22:53] - Use this type to install the following packages: zsh, mosh, emacs, nmap, sipcalc
******* DONE Create a `manifest` file in it - Edit the *initial manifest* and use **__my_computer** for **localhost**
CLOSED: [2020-05-06 수 22:53] - Match using the $__target_host variable
******* DONE Use this type to install the following packages: zsh, mosh, emacs, nmap, sipcalc ****** Modify your type to use a *for loop* to install the packages
CLOSED: [2020-05-06 수 22:53] ****** Deploy / manage your ~/.emacs file in this type
******* DONE Edit the *initial manifest* and use **__my_computer** for **localhost** - Ensure that permissions and ownership are correct
CLOSED: [2020-05-06 수 22:53] ****** Use different *verbosity* levels when configuring
******* DONE Match using the $__target_host variable ****** Ensure that all your changes are committed and pushed in your ungleich-learning-circle repository
CLOSED: [2020-05-06 수 22:53] - Use magit inside emacs for that
****** DONE Modify your type to use a *for loop* to install the packages ***** Documentation steps to be done in cdist.org
CLOSED: [2020-05-06 수 22:53] - Create a new org document named `cdist.org` in the same folder as the learning.org file
****** DONE Deploy / manage your ~/.emacs file in this type - Explain the difference between a singleton and non-singleton type
CLOSED: [2020-05-06 수 22:53] - Explain the difference between the different verbosity levels
******* DONE Ensure that permissions and ownership are correct - Document (copy&paste) some of the cdist runs in a "log" section```
CLOSED: [2020-05-06 수 22:53]
****** DONE Use different *verbosity* levels when configuring
CLOSED: [2020-05-06 수 22:54]
****** DONE Ensure that all your changes are committed and pushed in your ungleich-learning-circle repository
CLOSED: [2020-05-06 수 22:54]
******* DONE Use magit inside emacs for that
CLOSED: [2020-05-06 수 22:54]
***** DONE Documentation steps to be done in cdist.org
CLOSED: [2020-05-06 수 23:02]
****** DONE Create a new org document named `cdist.org` in the same folder as the learning.org file
CLOSED: [2020-05-06 수 23:02]
****** DONE Explain the difference between a singleton and non-singleton type
CLOSED: [2020-05-06 수 23:02]
****** DONE Explain the difference between the different verbosity levels
CLOSED: [2020-05-06 수 23:02]
****** Document (copy&paste) some of the cdist runs in a "log" section```
* 2020-05-04 * 2020-05-04
*** cdist #1: Introduction *** cdist #1: Introduction
**** Lecture content **** Lecture content
***** Objective ***** Objective
****** Begin to use cdist - Begin to use cdist
***** Steps ***** Steps
****** DONE Checkout cdist quickstart https://www.cdi.st/manual/latest/cdist-quickstart.html - Checkout cdist quickstart https://www.cdi.st/manual/latest/cdist-quickstart.html
CLOSED: [2020-05-04 월 22:32] - Install cdist locally
****** DONE Install cdist locally - Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist
CLOSED: [2020-05-04 월 22:32] - Create an empty initial manifest ("use touch")
****** DONE Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist - Commit that status
CLOSED: [2020-05-04 월 22:32] - Ensure that you can login as root to localhost via ssh without a password
****** DONE Create an empty initial manifest ("use touch") - Configure cdist to configures the motd of your localhost
CLOSED: [2020-05-04 월 22:32] - Ensure you have a case block matching on $__target_host
****** DONE Commit that status - Use the -c parameter to cdist to specify the configuration directory
CLOSED: [2020-05-04 월 22:37] - Use the -vv parameter to get more verbose output
****** DONE Ensure that you can login as root to localhost via ssh without a password - Search for / understand what MOTD stands for
CLOSED: [2020-05-04 월 22:37] - Configure cdist to create the file /etc/cdist-configured
****** DONE Configure cdist to configures the motd of your localhost - Configure cdist to setup the timezone on your local computer
CLOSED: [2020-05-05 화 00:42] - Configure cdist to ensure emacs is installed
******* DONE Ensure you have a case block matching on $__target_host - Ensure that in the end all changes are committed in your repository
CLOSED: [2020-05-05 화 00:21]
******* DONE Use the -c parameter to cdist to specify the configuration directory
CLOSED: [2020-05-04 월 23:58]
******* DONE Use the -vv parameter to get more verbose output
CLOSED: [2020-05-04 월 23:57]
******* DONE Search for / understand what MOTD stands for
CLOSED: [2020-05-05 화 00:41]
****** DONE Configure cdist to create the file /etc/cdist-configured
CLOSED: [2020-05-04 월 23:33]
****** DONE Configure cdist to setup the timezone on your local computer
CLOSED: [2020-05-04 월 23:33]
****** DONE Configure cdist to ensure emacs is installed
CLOSED: [2020-05-04 월 23:47]
****** DONE Ensure that in the end all changes are committed in your repository
CLOSED: [2020-05-05 화 00:42]
* 2020-05-01 * 2020-05-01
*** Organisation #5: Emacs refresher *** Organisation #5: Emacs refresher
**** Lecture content **** Lecture content
***** Objective: get confident with emacs commands ***** Objective: get confident with emacs commands
***** Find out and document how to do the following steps ***** Find out and document how to do the following steps
****** DONE Search for something forward C-s - Search for something forward C-s
CLOSED: [2020-05-01 금 21:40] - How to continue searching C-s C-s
****** DONE How to continue searching C-s C-s - Search for something backward C-r
CLOSED: [2020-05-01 금 21:43] - Search for regular expressions instead of string (forward, backward) C-M-s C-M-r
****** DONE Search for something backward C-r - Go to the beginning of the line C-a
CLOSED: [2020-05-01 금 21:55] - Go to the end of the line C-e
****** DONE Search for regular expressions instead of string (forward, backward) C-M-s C-M-r - Delete a word in front (to the right of the cursor) M-d
CLOSED: [2020-05-01 금 22:25] - Delete a word in back (to the left of the cursor) M-BackSpace
****** DONE Go to the beginning of the line C-a - List all "occurences" of a word in a file M-s o
CLOSED: [2020-05-01 금 22:16] - You can copy above instructions into an emacs buffer
****** DONE Go to the end of the line C-e - And test it by showing all occurences of the word "Search"
CLOSED: [2020-05-01 금 22:16] - Search (GREP) for a word in all files in a directory RECURSIVELY M-x rgrep
****** DONE Delete a word in front (to the right of the cursor) M-d - Save the CURRENT buffer C-x C-s
CLOSED: [2020-05-01 금 22:17] - Save ALL open files C-x-s
****** DONE Delete a word in back (to the left of the cursor) M-BackSpace - Split the window/buffer vertically C-x 2
CLOSED: [2020-05-01 금 22:18] - Split the window/buffer horizontally C-x 3
****** DONE List all "occurences" of a word in a file M-s o - Switch between the different windows C-x o
CLOSED: [2020-05-01 금 22:53] - Close all buffers besides the active one C-x 1
******* You can copy above instructions into an emacs buffer - Don't kill it!
******* And test it by showing all occurences of the word "Search" - Close only the active buffer C-x 0
****** DONE Search (GREP) for a word in all files in a directory RECURSIVELY M-x rgrep -* Don't kill it!
CLOSED: [2020-05-01 금 22:46] - Kill the active buffer C-x k
****** DONE Save the CURRENT buffer C-x C-s - Describe/Explain the difference between closing and killing
CLOSED: [2020-05-01 금 21:55] - closing is that emac do not display the buffer. and the contents on the buffer are kept on behined screen.
****** DONE Save ALL open files C-x-s - killing is that emac delete the buffer. and if contents are not stored, it is losted
CLOSED: [2020-05-01 금 22:22] - Switch between buffers that are not shown C-x b
****** DONE Split the window/buffer vertically C-x 2 - Document two very similar, but slightly different ways
CLOSED: [2020-05-01 금 21:48] - C-x b is that the selected buffer is displayed on the focused window
****** DONE Split the window/buffer horizontally C-x 3 - C-x C-b is that all buffers is dispalayed on the new window
CLOSED: [2020-05-01 금 21:48] - C-x 4 b is that the selected buffer is displayed on the new window
****** DONE Switch between the different windows C-x o
CLOSED: [2020-05-01 금 21:48]
****** DONE Close all buffers besides the active one C-x 1
CLOSED: [2020-05-01 금 21:47]
******* Don't kill it!
****** DONE Close only the active buffer C-x 0
CLOSED: [2020-05-01 금 21:54]
******* Don't kill it!
****** DONE Kill the active buffer C-x k
CLOSED: [2020-05-01 금 21:44]
****** DONE Describe/Explain the difference between closing and killing
CLOSED: [2020-05-01 금 22:09]
******* closing is that emac do not display the buffer. and the contents on the buffer are kept on behined screen.
******* killing is that emac delete the buffer. and if contents are not stored, it is losted
****** DONE Switch between buffers that are not shown C-x b
CLOSED: [2020-05-01 금 21:51]
******* DONE Document two very similar, but slightly different ways
CLOSED: [2020-05-01 금 23:28]
******** C-x b is that the selected buffer is displayed on the focused window
******** C-x C-b is that all buffers is dispalayed on the new window
******** C-x 4 b is that the selected buffer is displayed on the new window
***** Outcome ***** Outcome
****** DONE Document all above commands in your learning org sheet - Document all above commands in your learning org sheet
CLOSED: [2020-05-01 금 23:28] - Share your documentation at the end of the session (not before)
****** DONE Share your documentation at the end of the session (not before)
CLOSED: [2020-05-01 금 23:28]
* 2020-04-29 * 2020-04-29
*** Organisation #4: Organising yourself *** Organisation #4: Organising yourself
**** Lecture content **** Lecture content
***** Objective: have a todo list based on org mode ***** Objective: have a todo list based on org mode
***** Steps ***** Steps
****** Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/ - Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/
******* This is important as it will be used by the todo function later - This is important as it will be used by the todo function later
****** Extend your function from the organisation #1 session - Extend your function from the organisation #1 session
******* Instead of opening a fixed file, we include two variable parts: - Instead of opening a fixed file, we include two variable parts:
******** The hostname of the machine - The hostname of the machine
******** The year - The year
******* Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org - Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org
******** we call this "your personal agenda" - we call this "your personal agenda"
****** Configure mu4e to create a org-mode tasks from an email - Configure mu4e to create a org-mode tasks from an email
******* Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org - Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org
****** Configure emacs to open the "org-agenda" with "C-c a" - Configure emacs to open the "org-agenda" with "C-c a"
****** List all TODO entries - List all TODO entries
****** List the agenda of the day - List the agenda of the day
****** List the agenda of the week - List the agenda of the week
****** Bind F8 to open the "org-todo-list" - Bind F8 to open the "org-todo-list"
****** Create some sample tasks in it - Create some sample tasks in it
***** From now on, maintaining tasks should be ***** From now on, maintaining tasks should be
****** Pressing F3 to open your personal "logfile" - Pressing F3 to open your personal "logfile"
****** Adding a TODO item - Adding a TODO item
****** Pressing F8 to see the tasks with priorities - Pressing F8 to see the tasks with priorities
***** Bonus tasks ***** Bonus tasks
****** Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org - Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org
* 2020-04-27 * 2020-04-27
*** Organisation #3: Managing your emails *** Organisation #3: Managing your emails
**** Lecture content **** Lecture content
***** Objective ***** Objective
****** Be able to manage all your mails in mu4e - Be able to manage all your mails in mu4e
***** Description ***** Description
****** All email is synchronised using isync/mbsync - All email is synchronised using isync/mbsync
****** Email is indexed with mu (xapian backend) - Email is indexed with mu (xapian backend)
****** Email is viewed in mu4e - Email is viewed in mu4e
****** All new emails arrive in the inbox - All new emails arrive in the inbox
***** Steps ***** Steps
****** Install mu4e - Install mu4e
****** Start mu4e in emacs - Start mu4e in emacs
****** Configure mbsync for your ungleich mail account - Configure mbsync for your ungleich mail account
******* Synchronise all mails into ~/Maildir/ungleich - Synchronise all mails into ~/Maildir/ungleich
******* This structure leaves room for other mail accounts, like ~/Maildir/gmail - This structure leaves room for other mail accounts, like ~/Maildir/gmail
****** Verify that mbsync synchronises the mail - Verify that mbsync synchronises the mail
****** Index mails using `mu` on the command line (only first time) - Index mails using `mu` on the command line (only first time)
****** Configure mu4e to get email with mbsync -a - Configure mu4e to get email with mbsync -a
****** Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/ - Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/
******* This gives you a good performance / organisation for the next decades - This gives you a good performance / organisation for the next decades
****** Configure mu4e/emacs for sending emails - Configure mu4e/emacs for sending emails
****** Send other participants an email via mu4e - Send other participants an email via mu4e
****** Verify that it arrives - Verify that it arrives
****** "Archive" it afterwards - "Archive" it afterwards
* 2020-04-24 * 2020-04-24
*** Organisation #2: Creating, managing and sharing with "magit" *** Organisation #2: Creating, managing and sharing with "magit"
**** Lecture content **** Lecture content
***** Install "magit" for emacs ***** Install "magit" for emacs
***** Bind C-x g to open magit-status in ~/.emacs ***** Bind C-x g to open magit-status in ~/.emacs
***** Create a new directory ~/ungleich-learning-circle/ (with emacs) ***** Create a new directory ~/ungleich-learning-circle/ (with emacs)
****** Use C-h b in dired mode to find out how to - Use C-h b in dired mode to find out how to
***** Create a sub directory ~/ungleich-learning-circle/YOURNAME/ (with emacs) ***** Create a sub directory ~/ungleich-learning-circle/YOURNAME/ (with emacs)
***** Move your previously created learning.org file into ~/ungleich-learning-circle/YOURNAME/ (with emacs) ***** Move your previously created learning.org file into ~/ungleich-learning-circle/YOURNAME/ (with emacs)
***** Initialise it with git (with magit) ***** Initialise it with git (with magit)
@ -342,4 +319,4 @@
***** Create a function that opens ~/learning.org in your ~/.emacs ***** Create a function that opens ~/learning.org in your ~/.emacs
***** Bind that function to "f3" (configure it in .emacs) ***** Bind that function to "f3" (configure it in .emacs)
***** Create a new item named "2020-04-10" ***** Create a new item named "2020-04-10"
****** Create a sub item "ungleich learning circle" - Create a sub item "ungleich learning circle"

View file

@ -0,0 +1,8 @@
#print("Hello World!")
print("Hello Again")
print("I like typeing this.")
print("This is fun")
print('Yay! Printing.')
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')
print("Ungleich Cidst\n")

View file

@ -0,0 +1,29 @@
tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\ a \\ cat."
fat_cat = """
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
"""
fat_cat_single = '''
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
'''
new_test = """
\t tap \a BELL \r CR \f FF
\\ \u0032 \U00000033
"""
print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat)
print(fat_cat_single)
print(new_test)

View file

@ -0,0 +1,12 @@
#print("How old are you?", end=' ')
#age = input()
#print("How tall are you?", end=' ')
#height = input()
#print("How much do you weigh?", end=' ')
#weight = input()
age = input("How old are you?" ' ')
height = input("How tall are you?" ' ')
weight = input("How much do you weigh?" ' ')
print(f"So, you're {age} old, {height} tall and {weight} heavy.")

View file

@ -0,0 +1,5 @@
age = input("How old are you? ")
height = input("How tall are you? ")
weight = input("How much do you weigh? ")
print(f"So, you're {age} old, {height} tall and {weight} heavy.")

View file

@ -0,0 +1,9 @@
from sys import argv
# read the WYSS section for how to run this
script, first, second, third, fourth = argv
print("The script is called:", script)
print("Your first variable is:", first)
print("Your second variable is:", second)
print("Your third variable is:", third)
print("Your fourth variable is:", fourth)

View file

@ -0,0 +1,22 @@
from sys import argv
script, user_name, age = argv
prompt = '$ '
print(f"Hi {user_name}, I'm the {script} script.")
print("I'd like to ask you a few questions.")
print(f"Do you like me {user_name}?")
likes = input(prompt)
print(f"Where do you live {user_name}?")
lives = input(prompt)
print("What kind of computer do you have?")
computer = input(prompt)
print(f"""
Alright, so you said {likes} about liking me.
You live in {lives}. Not sure where that is.
And you have a {computer} computer. Nice.
Opps, You are {age} years old.
""")

View file

@ -0,0 +1,9 @@
# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.
print("I could have code like this.") # and the comment after is ignored
# You can also use a comment to "disable" or comment out code:
# print("This won't run.")
print("This will run.")

View file

@ -0,0 +1,9 @@
f_pi = 3.14159265358979
print("org =", f_pi)
print("trans format 1 = %.2f" % f_pi)
print("trans format 2 =", round(f_pi, 2))
print("trans format 3 = %.2f" % round(f_pi, 2))
print("trans format 4 = {:.2f}".format(f_pi))
print("trans format 5 = {:.2f}".format(round(f_pi, 2)))
print("trans format 6 = {:.15f}".format(round(f_pi, 2)))

View file

@ -0,0 +1,4 @@
print((2**8) - 1)
print((2**16) - 1)
print((2**32) - 1)
print((2**64) - 1)

View file

@ -0,0 +1,23 @@
print("I will now count my chickens:")
print("Hens", 25 + 30 / 6) # 25 + (30 / 6) = 25 + 5 = 30
print("Roosters", 100 - 25 * 3 % 4) # 100 - (25 * 3 % 4) = 100 - (75 % 4) = 100 - 3 = 97
print("Now I will count the eggs:") # print syntex
print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) # 3 + 2 + 1 - 5 + 0 - 0.25 + 6 = 6.75
print("Is it true that 3 + 2 < 5 - 7?") # print syntex
print(3 + 2 < 5 - 7) # 5 < -2 => false
print("What is 3 + 2?", 3 + 2) # 5
print("What is 5 - 7?", 5 - 7) # -2
print("Oh, that's why it's False.") # print syntex
print("How about some more.") # print syntex
print("Is it greater?", 5 > -2) # true
print("Is it greater or equal?", 5 >= -2) # true
print("Is it less or equal?", 5 <= -2) # false

View file

@ -0,0 +1,17 @@
cars = 100 # amount of car
space_in_a_car = 4.0 # amount of seats in the car
drivers = 30 # amount of driver
passengers = 90 # amount of passenger
cars_not_driven = cars - drivers # amount of person which could not drive = 70
cars_driven = drivers # amount of person which could drive = 30
carpool_capacity = cars_driven * space_in_a_car # amount of seat for carpool = 120
average_passengers_per_car = passengers / cars_driven # 3
print("There are", cars, "cars available.")
print("There are only", drivers, "drivers available.")
print("There will be", cars_not_driven, "empty cars today.")
print("We can transport", carpool_capacity, "people today.")
print("We have", passengers, "to carpool today.")
print("We need to put about", average_passengers_per_car,
"in each car.")

View file

@ -0,0 +1,24 @@
name = 'Zed A. Shaw'
age = 35 # not a lie
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
inch_to_cm = 2.54
lbs_to_kg = 0.45359237
cm_height = height * inch_to_cm
kg_weight = weight * lbs_to_kg
print(f"Let's talk about {name}.")
print(f"He's {height} inches or {cm_height} cm tall. ")
print(f"He's {weight} pounds or {kg_weight} kg heavy.")
print("Actually that's not too heavy.")
print(f"He's got {eyes} eyes and {hair} hair.")
print(f"His teeth are usually {teeth} depending on the coffee.")
# this line is tricky, try to get it exactly right
total = age + height + weight
print(f"If I add {age}, {height}, and {weight} I get {total}.")

View file

@ -0,0 +1,23 @@
types_of_people = 10 # define a value
x = f"There are {types_of_people} types of people." # define a string with the value "types_of_people"
binary = "binary" # define a string
do_not = "don't" # define a string
y = f"Those who know {binary} and those who {do_not}." # define a string with two string array
print(x) # print "There are 10 types of people."
print(y) # print "Those who know binary and those who don't."
print(f"I said: {x}") # print "I said: There are 10 types of people."
print(f"I also said: '{y}'") # print "I also said: 'Those who know binary and those who don't.'"
hilarious = False # define a value
joke_evaluation = "Isn't that joke so funny?! {}" # define a string
print(joke_evaluation.format(hilarious)) # print some format string
w = "This is the left side of..." # define a value
e = "a string with a right side." # define a value
print(w + e) # print a

View file

@ -0,0 +1,21 @@
print("Mary had a little lamb.") # print scipts
print("Its fleece was white as {}.".format('snow')) # print scipts
print("And everywhere that Mary went.") # print scipts
print("." * 10) # what'd that do? # print dot 10 times
end1 = "C" # define a character
end2 = "h" # define a character
end3 = "e" # define a character
end4 = "e" # define a character
end5 = "s" # define a character
end6 = "e" # define a character
end7 = "B" # define a character
end8 = "u" # define a character
end9 = "r" # define a character
end10 = "g" # define a character
end11 = "e" # define a character
end12 = "r" # define a character
# watch end = ' ' at the end. try removing it to see what happens
print(end1 + end2 + end3 + end4 + end5 + end6, end=' ') # print "Cheese "
print(end7 + end8 + end9 + end10 + end11 + end12) # print "Burger"

View file

@ -0,0 +1,12 @@
formatter = "{} {} {} {}"
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
"Try your",
"Own text here",
"Maybe a poem",
"Or a song about fear"
))

View file

@ -0,0 +1,14 @@
# Here's some new strange stuff, remember type it exactly.
days = "Mon Tue Wed Thu Fri Sat Sun" # define a string
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" # define a string
print("Here are the days: ", days) # print the days in a week
print("Here are the months: ", months) # print the months in a year with new lines
print("""
There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
""") # print multiple lines with three double-quotes

34
youngjin.han/python.org Normal file
View file

@ -0,0 +1,34 @@
* 2020-05-20
** note
- ex8.py
- none
- ex9.py
- none
- ex10.py
- none
- ex11.py
- none
- ex12.py
- pydoc input
- describe input on python. It looks like man commnad on linux shell.
- ex13.py
- none
- ex14.py
- none
* 2020-05-18
** note
- ex1.py
- # is commnet.
- ex2.py
- I do't find mistakes.
- ex3.py
- none
- ex4.py
- car_pool_capacity is not defined.
- ex5.py
- none
- ex6.py
- + is to add two string array.
- ex7.py
- none