User:Euna/prototyping 13: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with " =Prototyping 1= ==JupiterLab== - command language : pythone (also, wiki language. ex. instead of #, use ==headline==) - run on offline + in browser (easy to publish) - h...")
 
No edit summary
Line 1: Line 1:


=Prototyping 1=
=Prototyping 1 (20/09/2020)=





Revision as of 01:18, 24 September 2020

Prototyping 1 (20/09/2020)

JupiterLab

- command language : pythone (also, wiki language. ex. instead of #, use ==headline==)

- run on offline + in browser (easy to publish)

- have its library, with ? at the end (ex. random?), we get its explanation

- with "enter", change the line in the cell

- "enter + shift", command to execute the command -> on the next line, spit out the output immediately (like javascript console)

- consist of "Console" and "Notebook"


Console

-like terminal, command line interface. direct way to see the result, but, cannot be saved


Notebook

- for hybrid publishing interface (but +, console)

- fast editing and publishing possiblle ( faster than using hub)

- Text (Markdown) + Code (Python)

- modifying / rerunning the cell is possible

- Refer "AHOUSEOFDUST.ipynb" on JupiterLab


Phython code

- https://docs.python.org/3/tutorial/classes.html#class-objects

- "17" + 29 -> error / "17" + "29" -> 1729

- x=x+1 same with x+=1

- type : str (for text ex. "17"), int(number), float(number with fractional parts), boolean(true/false), list

- calculation with text is not possible (sauf, * ex."hello"*2 -> hellohello)

- x=["a", "b", "c"] -> x[1]=b / x[-1]=c(negative number starts from the end)

- print() -> empty line output

- for For, the space before inner-command is important

for x in "Michael":
    print(f"hello {x}")
print("End") 

-> hello M 
   hello i
   ... 
   hello l
   End  # appeals only at the end

- input random

random.random -> 0.234546546678

random.randint(0,5) -> 4 (random number between 0-4)

random.randint(0,len(x)) -> 1 (number between 0-2)

random.choice(x) -> c


Generated poem

- A house of dust by Alison Knowles https://hub.xpub.nl/bootleglibrary/read/465/pdf

- My generated poem input and output

import random
from random import choice

ani = ("mosquitos", "pigs", "kangaroos", "tunas", "cats")

cha = ("blue", "laziest", "numbest", "most stinky", "dullest")

for x in range (10) :
    n = random.randint(3, 30)   # when the number is too big, doesn't give a sufficient random one (like, 99999 -> always, a number of 5 ciphers)
    a = choice(ani)
    c1 = choice(cha)
    c2 = list(cha)   # to remove an element in tuple, must change to list (list = ["",""], tuple = ("","")
    c2.remove(c1)    # c2 is a list except the result of c1
    c2 = choice(c2)
    print(f"Amongst the numbers of {n} of {a},")
    print(f"the {c1} one and {c2} one are selected as the king and queen of {a}!")
    print()
Amongst the numbers of 5 of mosquitos,
the blue one and dullest one are selected as the king and queen of mosquitos!

Amongst the numbers of 13 of cats,
the laziest one and dullest one are selected as the king and queen of cats!

Amongst the numbers of 12 of cats,
the dullest one and most stinky one are selected as the king and queen of cats!

Amongst the numbers of 11 of kangaroos,
the numbest one and blue one are selected as the king and queen of kangaroos!

Amongst the numbers of 7 of cats,
the dullest one and blue one are selected as the king and queen of cats!

Amongst the numbers of 26 of tunas,
the laziest one and numbest one are selected as the king and queen of tunas!

Amongst the numbers of 6 of tunas,
the laziest one and dullest one are selected as the king and queen of tunas!

Amongst the numbers of 13 of pigs,
the numbest one and dullest one are selected as the king and queen of pigs!

Amongst the numbers of 4 of kangaroos,
the numbest one and blue one are selected as the king and queen of kangaroos!

Amongst the numbers of 18 of pigs,
the laziest one and blue one are selected as the king and queen of pigs!