Compare commits

...

49 Commits

Author SHA1 Message Date
Nico Schottelius de2f6d0749 Merge remote-tracking branch 'youngjin/master' 2020-05-22 17:12:04 +02:00
Nico Schottelius 33caf24cb7 Merge remote-tracking branch 'sami/master' 2020-05-22 17:09:56 +02:00
Nico Schottelius eb35717bd9 Merge remote-tracking branch 'origin/master' 2020-05-22 17:09:47 +02:00
samialazar 93e9083608 pushing until ex.21 2020-05-22 16:48:04 +02:00
samialazar b4071ec660 pushing using magit yay 2020-05-22 16:35:56 +02:00
samialazar d2e57f15f2 ex14 2020-05-20 16:28:40 +02:00
youngjin.han b68eb529a1 Learning Circle : python #2 - ex13, ex14 2020-05-20 22:47:36 +09:00
youngjin.han c0b8006422 Learning Circle : python #2 - ex11, ex12 2020-05-20 22:17:57 +09:00
youngjin.han 64bc3ef9f2 Learning Circle : python #2 - ex10 2020-05-20 22:00:32 +09:00
youngjin.han 48671bd220 Learning Circle : python #2 - ex8, ex9 2020-05-20 21:42:42 +09:00
youngjin.han 72ed0f808e Learning Circle : python #1 - ex7 2020-05-19 23:45:50 +09:00
samialazar ed8222535a python the hard way ex upto ex13 2020-05-19 16:28:33 +02:00
youngjin.han 070ef33f38 Learning Circle : python #1 - ex6 2020-05-19 00:34:11 +09:00
Nico Schottelius e3a5d69b5e Merge remote-tracking branch 'sami/master' 2020-05-18 17:03:58 +02:00
Nico Schottelius f0cb68c228 Merge remote-tracking branch 'origin/master' 2020-05-18 17:03:17 +02:00
youngjin.han 2531ef78c5 Learning Circle : pytion #1 - ex5 2020-05-19 00:00:27 +09:00
samialazar dab9fe5912 python the hard way ex. 2020-05-18 16:51:02 +02:00
youngjin.han 526f0688a1 Learning Circle : python #1 - ex3, ex4 2020-05-18 23:32:23 +09:00
youngjin.han 8ccbd1f8e2 Learning Circle : python #1 - ex2 2020-05-18 22:29:08 +09:00
youngjin.han 511e667d40 Learning Circle : python #1 - ex1 2020-05-18 22:09:58 +09:00
youngjin.han e28b8cbcbd Learning Circle : cdist #6 - update 1 2020-05-18 00:00:22 +09:00
youngjin.han a21705179c Learning Circle : cidst #6 :Initial commit 2020-05-18 00:00:22 +09:00
youngjin.han 91061f07fe Learning Circle : cdist #3 - update __my_dotfile 2020-05-18 00:00:22 +09:00
youngjin.han 65ddc29dbd Learning Circle : cdist #6 - update contents 2020-05-18 00:00:22 +09:00
youngjin.han 549b45fc4f Delete manifest~ 2020-05-18 00:00:22 +09:00
youngjin.han c4d7a41bc7 Delete gencode-remote~ 2020-05-18 00:00:22 +09:00
youngjin.han d869b8c938 Learning Circle : cdist #5 - update 3 2020-05-18 00:00:22 +09:00
youngjin.han 18f5b6abfb Learning Circle : cdist #5 - update 2 2020-05-18 00:00:15 +09:00
youngjin.han 7a5c11a44f Learning Circle : cdist #5 - update 1 2020-05-17 23:59:28 +09:00
youngjin.han 46e78f1a15 Learning Circle : cidst #5 - initial commit 2020-05-17 23:59:28 +09:00
youngjin.han 2a07d12665 Learning Circle : cdist #3 2nd commit 2020-05-17 23:59:28 +09:00
youngjin.han 182b2aa9df Learning Circle : cdist #3 initial commit 2020-05-17 23:59:28 +09:00
youngjin.han d8df3dbfcf Learning Circle : cdist #2 update cdist.org 2020-05-17 23:59:28 +09:00
youngjin.han 4f7f7995ea Learning Circle : cdist #2 update verbosity log 2020-05-17 23:59:28 +09:00
youngjin.han d6402038c5 Learning Circle : cdist #2 2020-05-17 23:59:28 +09:00
youngjin.han bace4a52cb Learning Circle : cdist #1 2020-05-17 23:59:28 +09:00
youngjin.han f7409f9de7 Learning Circle : update cdist init file 2020-05-17 23:59:28 +09:00
youngjin.han 5f5c31f896 Learning Circle : update file name 2020-05-17 23:59:28 +09:00
youngjin.han 9e07b9b21c Learning Circle : commit initial manifest for cdist 2020-05-17 23:59:28 +09:00
youngjin.han 6319638270 Learning Circle : clean up headline on todo file 2020-05-17 23:59:28 +09:00
youngjin.han 635550e1a5 Learning Circle : clean up remote repository 2020-05-17 23:59:28 +09:00
youngjin.han 1087ac1ae7 Learning Circle : Lecture 1,2,3,4 Content Update 2020-05-17 23:59:28 +09:00
youngjin.han ece44fce1d Learning Circle : Lecture 4 - Bonus Track Update 2020-05-17 23:59:28 +09:00
youngjin.han 7e86b3ac4f Learning Circle : Lecture 5 2020-05-17 23:59:28 +09:00
youngjin.han 550479613d Initail Commit 2020-05-17 23:59:28 +09:00
Nico Schottelius 78646d5066 Merge remote-tracking branch 'youngjin/master' 2020-05-15 17:16:22 +02:00
Nico Schottelius 4f6e507eee Merge remote-tracking branch 'jinguk/master' 2020-05-15 17:16:18 +02:00
kjg a91fe34d4b remove trash file 2020-05-16 00:06:50 +09:00
youngjin.han 16decdf805 Learning Circle : cidst #6 :Initial commit 2020-05-16 00:05:44 +09:00
62 changed files with 1131 additions and 217 deletions

8
.gitignore vendored
View File

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

View File

@ -1 +0,0 @@
extra-packages

View File

@ -1,5 +0,0 @@
#!/bin/sh -e
if [! -f echo "diff /etc/my-nftables /etc/readnfrule"]; then
echo "nft -f /etc/my-nftables"
fi

View File

@ -1,40 +0,0 @@
#!/bin/sh
os=$(cat "$__global/explorer/os")
nft_path="/etc/my-nftables"
case "$os" in
alpine)
os_pkgs="netcat-openbsd and tshark"
;;
debian|devuan)
os_pkgs="netcat tshark"
;;
fedora)
os_pkgs="nmap-ncat wireshark-cli"
;;
*)
echo "OS $os currently not supported" >&2
exit 1
;;
esac
if [ ! -f "$__global/explorer/exists" ];then
echo "crrently no nft" >&2
exit 1
fi
if ["-" -eq "$__object/parameter/file" ]; then
filename="$__object/stdin"
else
filename=($__object/parameter/file)
fi
__file ${nft_path} --mode 644 --source "$__type/files/${filename}"
if [ -f "$__global/explorer/nfrule" ]; then
echo "$__global/explorer//nfrule" > /etc/readrule
fi

View File

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

View File

@ -0,0 +1 @@
sami@afro-linux-lenovo-b50-30.19806:1589891645

View File

@ -0,0 +1,4 @@
\#*#
*~

View File

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

View File

@ -0,0 +1,16 @@
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
"""
print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat)

View File

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

View File

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

View File

@ -0,0 +1,10 @@
#Parameters, Unpacking, Variables
from sys import argv
# read the WYSS section for how to run this
script, first, second, third = 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)

View File

@ -0,0 +1,21 @@
from sys import argv
script, user_name = 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}.
And you have a {computer} computer.
""")

View File

@ -0,0 +1,18 @@
from sys import argv
script, filename = argv
txt = open(filename)
print(f"Here's your file {filename}:")
print(txt.read())
print("Type the filename again:")
file_again = input("> ")
txt_again = open(file_again)
print(txt_again.read())

View File

@ -0,0 +1,41 @@
from sys import argv
script, filename = argv
print(f"We're going to erase {filename}.")
print("If you don't want that, hit CTRL-C (^C).")
print("If you do want that, hit RETURN.")
input("?")
print("Opening the file...")
target = open(filename, 'w')
print("Truncating the file.
target.truncate()
Goodbye!")
print("Now I'm going to ask you for three lines.")
line1 = input("line 1: ")
line2 = input("line 2: ")
line3 = input("line 3: ")
print("I'm going to write these to the file.")
target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")
print("And finally, we close it.")
target.close()

View File

@ -0,0 +1,28 @@
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print(f"Copying from {from_file} to {to_file}")
# we could do these two on one line, how?
in_file = open(from_file)
indata = in_file.read()
print(f"The input file is {len(indata)} bytes long")
print(f"Does the output file exist? {exists(to_file)}")
print("Ready, hit RETURN to continue, CTRL-C to abort.")
input()
out_file = open(to_file, 'w')
out_file.write(indata)
print("Alright, all done.")
out_file.close()
in_file.close()

View File

@ -0,0 +1,25 @@
# this one is like your scripts with argv
def print_two(*args):
arg1, arg2 = args
print(f"arg1: {arg1}, arg2: {arg2}")
# ok, that *args is actually pointless, we can just do this
def print_two_again(arg1, arg2):
print(f"arg1: {arg1}, arg2: {arg2}")
# this just takes one argument
def print_one(arg1):
print(f"arg1: {arg1}")
# this one takes no arguments
def print_none():
print("I got nothin'.")
print_two("Zed","Shaw")
print_two_again("Zed","Shaw")
print_one("First!")
print_none()

View File

@ -0,0 +1,26 @@
def cheese_and_crackers(cheese_count, boxes_of_crackers):
print(f"You have {cheese_count} cheeses!")
print(f"You have {boxes_of_crackers} boxes of crackers!")
print("Man that's enough for a party!")
print("Get a blanket.\n")
print("We can just give the function numbers directly:")
cheese_and_crackers(20, 30)
print("OR, we can use variables from our script:")
amount_of_cheese = 10
amount_of_crackers = 50
cheese_and_crackers(amount_of_cheese, amount_of_crackers)
print("We can even do math inside too:")
cheese_and_crackers(10 + 20, 5 + 6)
print("And we can combine the two, variables and math:")
cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)

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,46 @@
from sys import argv
script, input_file = argv
def print_all(f):
print(f.read())
def rewind(f):
f.seek(0)
def print_a_line(line_count, f):
print(line_count, f.readline())
current_file = open(input_file)
print("First let's print the whole file:\n")
print_all(current_file)
print("Now let's rewind, kind of like a tape.")
rewind(current_file)
print("Let's print three lines:")
current_line = 1
print_a_line(current_line, current_file)
current_line = current_line + 1
print_a_line(current_line, current_file)
current_line = current_line + 1
print_a_line(current_line, current_file)

View File

@ -0,0 +1,39 @@
def add(a, b):
print(f"ADDING {a} + {b}")
return a + b
def subtract(a, b):
print(f"SUBTRACTING {a} - {b}")
return a - b
def multiply(a, b):
print(f"MULTIPLYING {a} * {b}")
return a * b
def divide(a, b):
print(f"DIVIDING {a} / {b}")
return a / b
print("Let's do some math with just functions!")
age = add(30, 5)
height = subtract(78, 4)
weight = multiply(90, 2)
iq = divide(100, 2)
print(f"Age: {age}, Height: {height}, Weight: {weight}, IQ: {iq}")
# A puzzle for the extra credit, type it in anyway.
print("Here is a puzzle.")
what = add(age, subtract(height, multiply(weight, divide(iq, 2))))
print("That becomes: ", what, "Can you do it by hand?")

View File

@ -0,0 +1,5 @@
* What Do Know SO far?
** print : The print function in Python is a function that outputs to your console window whatever you say you want to print out.
**

View File

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

View File

@ -0,0 +1,16 @@
cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven
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,18 @@
my_name = 'Zed A. Shaw'
my_age = 35 # not a lie
my_height = 74 # inches
my_weight = 180 # lbs
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'
print(f"Let's talk about {my_name}.")
print(f"He's {my_height} inches tall.")
print(f"He's {my_weight} pounds heavy.")
print("Actually that's not too heavy.")
print(f"He's got {my_eyes} eyes and {my_hair} hair.")
print(f"His teeth are usually {my_teeth} depending on the coffee.")
# this line is tricky, try to get it exactly right
total = my_age + my_height + my_weight
print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total}.")

View File

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

View File

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

View File

@ -0,0 +1,13 @@
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,15 @@
# Here's some new strange stuff, remember type it exactly.
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
print("Here are the days: ", days)
print("Here are the months: ", months)
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.
""")

View File

@ -0,0 +1,28 @@
* Python
** Numbers and Math: Every programming language has some kind of way doing numbers and math
** Variables and Names : we need to use underscore with means an imaginary space between words in variable names
** a variable is nothing more than a name for something.
* Ex6 String and Text
** A string is usually a bit of text you want to display to someone or ”export” out of the program you are
writing
** Python knows you want something to be a string when you put either " (double-quotes) or '
(single-quotes) around the text
* Ex7 More Printing
** sometimes you cant use f string, f string can also be used as .format and pass it to variables
*** Example
- print("Its fleece was white as {}.".format('snow'))
- print(f"Its fleece was white as {'snow'}."
** You can multiply strings by a number
*** print ("." * 10) this will extend the string which is the . 10 times
** You can also combine strings
*** - print(end1 + end2 + end3 + end4 + end5 + end6, end=' ')
- print(end7 + end8 + end9 + end10 + end11 + end12)
* Ex8 Printing, Printing
**

View File

@ -0,0 +1,43 @@
*** cdist #6: Glueing it together
**** Lecture content
***** Objective
- Apply learnings from the previous cdist sessions
***** Steps 1: *__all_in_one* (1.25h)
- Create a new type named *__all_in_one*
- Decide yourself whether it is a singleton or not
- Reason why in your cdist.org file
- It should work on alpine, debian and fedora
- It accepts the following parameters:
- *--with-x* (boolean)
- *--extra-packages* (optional multiple)
- On Alpine, it should install netcat-openbsd and tshark
- On Debian, it should install netcat tshark
- On Fedora, it should install nmap-ncat wireshark-cli
- On all operating systems install socat sipcalc sudo
- If the detected operating system is neither
Alpine/Debian/Fedora, output an error message and abort the
manifest with exit code 1
- Additionally install all packages specified by the *--extra-packages* parameter
***** Steps 2: *__firewall* (1.25h)
- Create a new type *__my_firewall*
- Add a *type explorer* to find out whether nft is present on
the target system
- Add a required parameter named *file*
- If the type explorer does not detect nft on the target system,
abort with an error message
- Deploy the specified file to */etc/my-nftables*
- Add a *type explorer* that reads the current nft rules
- If the rules are different on the target host, apply the new
ruleset by generating code in *gencode-remote*
- If the filename specified by the *file* parameter is *-* (the
minus sign), then the type should read from *stdin*
***** Step 3: manifest (0.5h)
- Create a new manifest in the folder that contains the initial manifest
- Name the new manifest *firewall*
- Source the *firewall* manifest in the *initial* manifest
- In the *firewall* manifest, match on *localhost*
- Install nftables
- Use the *__firewall* type
- Use correct *require* parameter to ensure that nftables is
installed before the *__firewall* type is run

View File

@ -0,0 +1,42 @@
*** cdist #6: Glueing it together
**** Lecture content
***** Objective
- Apply learnings from the previous cdist sessions
***** Steps 1: *__all_in_one* (1.25h)
- Create a new type named *__all_in_one*
- Decide yourself whether it is a singleton or not
- Reason why in your cdist.org file
- It should work on alpine, debian and fedora
- It accepts the following parameters:
- *--with-x* (boolean)
- *--extra-packages* (optional multiple)
- On Alpine, it should install netcat-openbsd and tshark
- On Debian, it should install netcat tshark
- On Fedora, it should install nmap-ncat wireshark-cli
- On all operating systems install socat sipcalc sudo
- If the detected operating system is neither
Alpine/Debian/Fedora, output an error message and abort the
manifest with exit code 1
- Additionally install all packages specified by the *--extra-packages* parameter
***** Steps 2: *__firewall* (1.25h)
- Create a new type *__my_firewall*
- Add a *type explorer* to find out whether nft is present on
the target system
- Add a required parameter named *file*
- If the type explorer does not detect nft on the target system,
abort with an error message
- Deploy the specified file to */etc/my-nftables*
- Add a *type explorer* that reads the current nft rules
- If the rules are different on the target host, apply the new
ruleset by generating code in *gencode-remote*
- If the filename specified by the *file* parameter is *-* (the
minus sign), then the type should read from *stdin*
***** Step 3: manifest (0.5h)
- Create a new manifest in the folder that contains the initial manifest
- Name the new manifest *firewall*
- Source the *firewall* manifest in the *initial* manifest
- In the *firewall* manifest, match on *localhost*
- Install nftables
- Use the *__firewall* type
- Use correct *require* parameter to ensure that nftables is
installed before the *__firewall* type is run

View File

@ -0,0 +1,33 @@
*** cdist #3: type parameters
**** Lecture content
***** Create a new type named *__colourful_file*
- The objective is to create a type that creates colourful file
- The content of the file should be "colour=...", where "..." is
a colour specified by a parameter
- Add an *optional parameter* named *colour*
- Use the **__file** type inside your type to create a file
- Use the *$__object_id* variable inside your type
***** Extend your type to be more colourful
- Modify the *optional parameter* to be able to be specified
*multiple times*
- For each time it is specified, add a line "colour=..." to the file
***** Create a new type *__my_dotfiles*
- Objective is to manage the dotfiles in your home directory
- Make it a *singleton* type
- Create a sub directory *files* in the type
- Add your .emacs config to the files folder
- Add a *for* loop to your type to deploy .[A-z]* to your home directory
- Add a .bashrc or .zshrc to the files folder (depending on your shell)
- In the initial manifest, add __my_dotfiles when the target
host is localhost
***** As usual commit all changes to your ungleich-learning-circle repo
* Defining parameters
** Every type consists of required, optional and boolean parameters, which
must each be declared in a newline separated file in parameter/required,

View File

@ -2,12 +2,14 @@ __file /etc/cdist-configured
case "$__target_host" in
localhost)
__motd
__timezone Asia/Seoul
# __motd
# __timezone Asia/Seoul
# __my_computer
# __colourful_file --colour yellow --colour blue --colour red --colour green
# __my_dotfiles
# __my_nginx_site $__target_host
# __all_in_one --with-x --extra-packages tree --extra-packages htop
__my_firewall --file /etc/my-nftables
;;
jafo.laptop)
__motd

View File

@ -0,0 +1,42 @@
#!/bin/sh -e
os="$(cat "$__global/explorer/os")"
default_package_name="socat sipcalc sudo"
if [ -f "$__object/parameter/with-x" ]; then
with_x="$(cat "$__object/parameter/with-x")"
fi
case "$os" in
alpine)
name_netcat="netcat-openbsd"
name_wireshark="tshark"
;;
debian|devuan)
name_netcat="netcat"
name_wireshark="tshark"
;;
fedora)
name_netcat="nmap-ncat"
name_wireshark="wireshark-cli"
;;
*)
echo "Don't know how to manage packages on: $os" >&2
exit 1
:
;;
esac
all_package_name="$default_package_name $name_netcat $name_wireshark"
__package_update_index
for package in $all_package_name; do
require="__package_update_index" __package $package --state=present
done
if [ -f "$__object/parameter/extra-packages" ]; then
for package in $(cat "$__object/parameter/extra-packages"); do
require="__package_update_index" __package $package --state=present
done
fi

View File

@ -0,0 +1 @@
with-x

View File

@ -0,0 +1 @@
extra-packages

View File

@ -0,0 +1,11 @@
#!/bin/sh -e
if [ -x nft ]; then
echo "nft is founded"
else
echo "nft is not founded"
exit 1
fi
__file /etc/my_nftables \
--mode 0644

View File

@ -0,0 +1,44 @@
#!/bin/sh -e
os="$(cat "$__global/explorer/os")"
default_package_name="socat sipalc sudo"
if [ -f "$__object/parameter/with-x" ]; then
with_x="$(cat "$__object/parameter/with-x")"
else
with_x="$__object_id"
fi
case "$os" in
alpine)
name_netcat="netcat-openbsd"
name_wireshark="tshark"
;;
debian)
name_netcat="netcat"
name_wireshark="tshark"
;;
fedora)
name_netcat="nmap-ncat"
name_wireshark="wireshark-cli"
;;
*)
echo "Don't know how to manage packages on: $os" >&2
exit 1
:
;;
esac
all_package_name="$default_package_name $name_netcat $name_wireshark"
__package_update_index
for package in $all_package_name;
do require="__apt_update_index" __package $package --state=present
done
if [ -f "$__object/parameter/extra-packages" ]; then
for package in $(cat "$__object/parameter/extra-packages"); do
require="__apt_update_index" __package $package --state=present
done
fi

View File

@ -0,0 +1 @@
file

View File

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