::.. =[]= ..::     ::.. =[]= ..::     ::.. =[]= ..::     ::.. =[]= ..::
 

CgAn Course 9: Python 2/2

| November 13th, 2017 by Doemela | Comments Off on CgAn Course 9: Python 2/2

See https://archive.cyberguerrilla.org/a/2017/cgan-teach-the-world-about-hacking-hacktivism/

[Anon_Blackcat01] you can set topic with any links if you wish W4RL0RD
[W4RL0RD] Ye
[W4RL0RD] !topic Main Python Website https://www.python.org/ || Learn this https://www.python.org/dev/peps/pep-0008/ || Get Python for Windows here https://www.python.org/downloads/windows/ || Paste code https://bpaste.net/
*** Emma changes topic to “Main Python Website https://www.python.org/ || Learn this https://www.python.org/dev/peps/pep-0008/ || Get Python for Windows here https://www.python.org/downloads/windows/ || Paste code https://bpaste.net/”
[Chanlog] Title: Welcome to Python.org (at www.python.org)
[Battlemore] hello guys
[Battlemore] whats with the lesson 9?
[W4RL0RD] Hey.
[W4RL0RD] Ninth lesson of the season.
[W4RL0RD] Today is the last lesson.
[W4RL0RD] Will be about 2 hours.
[Battlemore] okay nice
[Battlemore] when was the first season started?
[W4RL0RD] This is the first season.
[W4RL0RD] First of November i think.
[Battlemore] whats the topic in python, was it the basic?
[Battlemore] like outputing print(“Hello WOrld”)?
[W4RL0RD] We talked about that yesterday.
[W4RL0RD] Today we will go more in-depth.
[Battlemore] so lets start
[W4RL0RD] Not yet.
[Battlemore] what time will start?
[W4RL0RD] In 15 minutes.
[Battlemore] okay ill wait
*** wyzzz is now known as cybernoob
[cybernoob] sur #lesson9
[cybernoob] oups sorry πŸ™‚
[Battlemore] hey cybernoob
[cybernoob] hello Battemore
[cybernoob] *Battlmore
[cybernoob] **Battlemore πŸ™‚
[Battlemore] are you the teacher here cybernoob?
[cybernoob] no Battlemore
[Battlemore] okay then who is going to start the review or study?
[cybernoob] I don’t know Battlemore
[W4RL0RD] I am the teacher.
[Battlemore] woah
[Battlemore] master_yoda is that you? xD
[cybernoob] πŸ™‚
[Battlemore] or Obi one?
[Mink] hey, i thought was an evening meeting, glad i’m around
*** cybernoob is now known as wyzzz
[W4RL0RD] Wanna start?
[TrevorC] sure
[W4RL0RD] Not a lot of people.
[wyzzz] πŸ™‚
[Battlemore] okay
[Battlemore] so where do we start then
[W4RL0RD] So welcome to another Python lesson.
[Mink] thanks W4RL0RD
[W4RL0RD] First i want to know if you have any experience with Python.
[TrevorC] I do a little. I just started learning
[wyzzz] thanks W4RL0RD
[W4RL0RD] Cool.
[wyzzz] πŸ˜‰
[W4RL0RD] So i guess you guys know the interpreter and the print statement.
[Battlemore] i have but not so good enough
[Battlemore] i know how to create functions
[W4RL0RD] Battlemore: Cool.
[W4RL0RD] https://archive.cyberguerrilla.org/a/2017/cgan-course-8-python101-introduction-to-programming/
[Chanlog] Title: CyberGuerrilla soApboX Β» Blog Archive Β» CgAn Course 8: Python101 – introduction to programming (at www.cyberguerrilla.org)
[W4RL0RD] That is the lesson we did two days ago.
[W4RL0RD] So once again.
[W4RL0RD] Let’s open a terminal and our favorite text editor.
[Battlemore] okay then
[Battlemore] me done
[W4RL0RD] Once the text editor is open we write #!/usr/bin/python3
[Battlemore] its just a comment
[W4RL0RD] No.
[wyzzz] no Battlemore
[Battlemore] what does it mean?
[Battlemore] why is it needed as a python programmer?
[W4RL0RD] BTW You guys have GNU/Linux or Windows?
[Battlemore] me Linux
[TrevorC] Using windows at the moment
[TrevorC] If it is easier for you i could switch to GNU/Linux
[W4RL0RD] Battlemore: A good question.
[W4RL0RD] TrevorC: Nah it’s ok.For now.
[Battlemore] can you explain ..? please im not used to it
[TheEnvious] Hai πŸ™‚
[W4RL0RD] Battlemore: Let’s say that it gives better control to the script-writer.
[Battlemore] oh,, okay
[W4RL0RD] Hey TheEnvious
[Battlemore] just to know if his using python2 or 3 right?
[W4RL0RD] In a few words it “talks” with the interpreter.
[W4RL0RD] Battlemore: No.
[W4RL0RD] It is not a comment.
[Battlemore] okay
[W4RL0RD] The Unix/Linux program loader looks the first two bytes of the file for #!.
[Battlemore] okay then.
[Battlemore] what will happen if you dont add those ?
[Battlemore] for i program using python by not adding those #!/bin/bash/python3
[W4RL0RD] In Windows nothing.
[W4RL0RD] Look.
[W4RL0RD] You have your editor open?
[Battlemore] okay i use Geany
[W4RL0RD] Cool.
[W4RL0RD] Write #1/usr/bin/python3
[W4RL0RD] And below that print(“Hello, World!”).
[W4RL0RD] Save the file somewhere and then cd there with your terminal.
[W4RL0RD] Save as test.py for example.
[Battlemore] done
[W4RL0RD] Then do chmod +x test.py.
[W4RL0RD] Now ./test.py.
[W4RL0RD] You see itprint.
[Battlemore] do i have to chmod it?
[W4RL0RD] Open it again and remove the line wit the #!.
[W4RL0RD] Yes.
[Battlemore] ./test.py: line 2: syntax error near unexpected token `”Hello WOrld”‘
[W4RL0RD] And then do ./test.py again.
[Battlemore] yeah it works xD
[Battlemore] woah, i just discovered it , just for now
[W4RL0RD] Let’s continue.
[Battlemore] ive been programming without using those
[W4RL0RD] Better Google why #!/usr/bin/python3 is needed.
[W4RL0RD] Anyway.
[W4RL0RD] Now let’s all go back to our editors.
[Battlemore] okay done
[W4RL0RD] Let’s write #!/usr/bin/python or python3(Unix/Linux users).
[W4RL0RD] If you are on Windows the #! line is not needed.
[W4RL0RD] After that let’s write x = 100.
[W4RL0RD] And then print(x).
[W4RL0RD] Save and execute once more.
[Battlemore] output: 100
[W4RL0RD] As you can see it printed out 100.
[W4RL0RD] The x is called a variable.
[Battlemore] then the 100 is the value right?
[W4RL0RD] Variables are just reserved memory to store values.
[W4RL0RD] Yes.
[W4RL0RD] You can store different types of data types.
[Battlemore] are we going to use a debugger to know where memory address is it registered?
[W4RL0RD] Like if we wanted our name we would do x = “Name”
[W4RL0RD] Notice the quotes.
[W4RL0RD] Battlemore: You are way ahead of yourself.
[Battlemore] oh sorry for that
[W4RL0RD] Every variable’s name is called an identifier.
[W4RL0RD] Also a Python identifier is the name of a class,object,function or any module.
[W4RL0RD] \An identifier cannot have punctuation characters,like @,!,&.
[W4RL0RD] Also Python is case sensitive.
[W4RL0RD] So Anonymous and anonymous are two different identifiers.
[W4RL0RD] Some naming conventions we should know.
[W4RL0RD] A class name starts with an uppercase letter.
[W4RL0RD] Starting an identifier with a single underscore indicates the identifier is private.
[TrevorC] So underscore means the variable is private
[W4RL0RD] Stating with two indicates is a strong private identifier.
[W4RL0RD] And if it also endas with two underscores the identifier is a language-defined specTreYe.ial name.
[W4RL0RD] special name*
[W4RL0RD] Now,there are some words that cannot be used as identifiers.
[W4RL0RD] They are the reserved words.
[W4RL0RD] And here they are https://bpaste.net/show/63d551be2fa4
[Chanlog] Title: show at bpaste (at bpaste.net)
[W4RL0RD] Also Python is all about the indentation.
[W4RL0RD] The right indentation is one TAB.
[W4RL0RD] Not four spaces cause that’s just retarded.
[Battlemore] wich means 4 spaces?
[W4RL0RD] Always one TAB.
[Battlemore] 4 spaces must be equal to one TAB
[W4RL0RD] Battlemore: 4 spaces is retarded.
[W4RL0RD] And sometimes breaks the code.
*** wyzzz is now known as Z80
[W4RL0RD] Look at this
[W4RL0RD] https://bpaste.net/show/25ee1559b0e4
[Chanlog] Title: show at bpaste (at bpaste.net)
[W4RL0RD] Just look the indentation.
[W4RL0RD] The space before the print.
[W4RL0RD] Let’s talk about the comments now.
[W4RL0RD] Comments in Python start with #.
[W4RL0RD] So # I am a comment.
[W4RL0RD] https://bpaste.net/show/9e72d66050f2
[Chanlog] Title: show at bpaste (at bpaste.net)
[W4RL0RD] https://bpaste.net/show/b6c562e89b42
[Chanlog] Title: show at bpaste (at bpaste.net)
[W4RL0RD] Input time.
[W4RL0RD] I want you guys to deleting everything in the file except the #! line.
[W4RL0RD] Write input(“\n\nPress enter to exit”)
[W4RL0RD] Save and execute.
[W4RL0RD] Ok?
[TrevorC] Yes, did what it said
[Battlemore] done
[W4RL0RD] Alright.
[Aspire] its not too late?
[W4RL0RD] Nah.
[Aspire] did you already started?
[W4RL0RD] Yes.
[Aspire] ok im sorry
[W4RL0RD] Nah it’s cool.
[W4RL0RD] Check the logs after
[Aspire] yes
[W4RL0RD] Let’s talk about Strings.
[W4RL0RD] String are identified as a cntiguous set of characters that go between quotation marks.
[W4RL0RD] Either single or double.
[TrevorC] is the a difference?
[TrevorC] there*
[B[U]G] already started?
[W4RL0RD] You can manipulate them with [] [:].
[W4RL0RD] B[U]G: Yes.
[W4RL0RD] Aspire: B[U]G Open a terminal and a text editor if you wanna follow a bit.
[Aspire] ok
[B[U]G] k
[W4RL0RD] If you are in Unix/Linux add #!/usr/bin/python or python3 on the top of the file.
[B[U]G] i would know how work a socket to make a connection and interact with various request on the internet
[W4RL0RD] If you are on Windows add nothing.
[B[U]G] linux
[W4RL0RD] B[U]G: We will talk another time for that.
[B[U]G] mh kk
[W4RL0RD] When you are done tell me.
[W4RL0RD] Also saver the file somewhere as test.py.
[B[U]G] i?
[B[U]G] im ready
[TheEnvious] B[U]G, https://tools.ietf.org/html/rfc793
[W4RL0RD] AAnd navigate to it with the terminal.
[Chanlog] Title: RFC 793 – Transmission Control Protocol (at tools.ietf.org)
[W4RL0RD] Aspire: Ready?
[Aspire] yes
[B[U]G] ty TheEnvious
[W4RL0RD] Ok.
[TheEnvious] Your welcome πŸ˜‰
[W4RL0RD] Now write str = “Hello, World!”.
[B[U]G] TheEnvious, i see but i know tcp protocl
[B[U]G] i would another thing
[W4RL0RD] Then print(str) save and run.
[W4RL0RD] Oh before youre chmod +x test.py and run with ./test..py.
[B[U]G] W4RL0RD, why you use str as variable ?
[W4RL0RD] B[U]G: str is just an identifier.
[W4RL0RD] So no reason.
[Aspire] it work
[B[U]G] ah ok beacuse in py2.7 is for mix various thing
[Aspire] works
[W4RL0RD] Aspire: Cool.
[Aspire] yes
[Aspire] Cool
[B[U]G] i thinks that this are py3 lesson right?
[B[U]G] anyway work asd
[W4RL0RD] TrevorC: Any errors?
[TrevorC] nope
[W4RL0RD] B[U]G: Well differences with 2 are not a lot so…
[W4RL0RD] Cool.
[Aspire] uhh
[W4RL0RD] Now type print(str[3:6]).Save and execute.
[W4RL0RD] Aspire: Yes?
[Aspire] its cool
[Aspire] ahaha
[TrevorC] Output: lo,
[W4RL0RD] Now add print(str[:2]).Save and execute.
[W4RL0RD] TrevorC: Exactly.
[W4RL0RD] You understand why?
[TrevorC] I think i do
[TrevorC] it has to do with the length
[TrevorC] we printed everything between the length of 3 and 6?
[W4RL0RD] To make sure the [:] is a splitter.
[W4RL0RD] Yes
[W4RL0RD] So if you do print(str[2:]).
[W4RL0RD] It will print from the 3rd character.
[TrevorC] Output: llo, World!
[Aspire] yes
[W4RL0RD] Now do print(str * 2)
[W4RL0RD] TrevorC: xD
[B[U]G] Hello, World!
[B[U]G] lo,
[B[U]G] Hello, World!Hello, World!
[W4RL0RD] LEL
[B[U]G] lmao
[W4RL0RD] Now print(str + “fuck”).
[W4RL0RD] Notice the quotes
[Aspire] Cool.
[B[U]G] Hello, World!fuck
[B[U]G] ashhuashu
[B[U]G] I would bet for a simple and fast and easy video lesson or its problem for privacy?
[W4RL0RD] Now do print(“First word: “, str[:5])
[W4RL0RD] YouTube is full of videos.
[W4RL0RD] This is better,at least for me,cause i interact with you.So if any errors occur we can solve them.
[B[U]G] well
[W4RL0RD] Now do print(“First word: “, str[:5])
[W4RL0RD] What is the output?
[TrevorC] Output: hello
[B[U]G] (‘First word: ‘, ‘Hello’)
[TrevorC] First word: hello*
[Aspire] yes
[W4RL0RD] TrevorC: No parentheses and shit?
[TrevorC] No
[W4RL0RD] B[U]G: Weird output.
[B[U]G] i crash
[B[U]G] [B[U]G] (‘First word: ‘, ‘Hello’)
[W4RL0RD] Ye.
[W4RL0RD] What is your code?
[B[U]G] print(“First word: “, str[:5])
[B[U]G] str = “Hello, World!”;
[B[U]G] print(str)
[B[U]G] print(str[3:6])
[B[U]G] print(str * 2)
[B[U]G] print(str + “fuck”)
[B[U]G] print(“First word: “, str[:5])
[W4RL0RD] You in Windows?
[B[U]G] no , debian
[Aspire] str = “Hello, World!”
[Aspire] print (str)
[Aspire] print(str[3:6])
[Aspire] print(str[2:])
[Aspire] print(str * 2)
[Aspire] print(str + ” fuck”)
[Aspire] print(“First word: “, str[:5])
[W4RL0RD] You have #!/usr/bin/python3?
[Aspire] oh sorry
[W4RL0RD] B[U]G: Add #1/usr/bin/python3 and ccheck again.
[B[U]G] k
[B[U]G] work πŸ™‚
[W4RL0RD] No parenteses right
[W4RL0RD] ?
[B[U]G] same parentesess
[B[U]G] (‘First word: ‘, ‘Hello’)
[W4RL0RD] Weird.
[TrevorC] indeed…
[W4RL0RD] B[U]G: Do python3 on your terminal.
[B[U]G] idle run correctly
[B[U]G] try from here
[B[U]G] ?
[W4RL0RD] No.
[W4RL0RD] Just do python3
[B[U]G] ok
[B[U]G] ]]] str = “Hello, World!”;
[B[U]G] ]]] print(“First word: “, str[:5])
[B[U]G] First word: Hello
[B[U]G] work correctly
[W4RL0RD] I see.
[W4RL0RD] But why not from the text editor?
[B[U]G] i think
[W4RL0RD] You run it with ./test.py?
[B[U]G] i have
[B[U]G] two instance
[B[U]G] right
[B[U]G] i have loaded script simply python test.py
[TheEnvious] run it with: python test.py
[B[U]G] but
[B[U]G] is
[TheEnvious] or python2
[B[U]G] python4
[B[U]G] python4 test.py
[B[U]G] python3 test.py
[B[U]G] it correct
[B[U]G] Hello, World!
[B[U]G] lo,
[B[U]G] Hello, World!Hello, World!
[B[U]G] Hello, World!fuck
[B[U]G] First word: Hello
[W4RL0RD] Really?
[TheEnvious] That’s depend of your symlink ^^
[W4RL0RD] And not with ./test.py?
[B[U]G] yeah
[TheEnvious] Try: whereis python3
[B[U]G] no work
[W4RL0RD] Maybe the path is not set up properly.
[B[U]G] lol
[B[U]G] work work
[B[U]G] shuashuhsuh
[B[U]G] lmao
[TheEnvious] And replace your interepreter path
[W4RL0RD] LOL how?
[B[U]G] AHAHAHAHHAHAHAHAHAHHAAHHA
[W4RL0RD] Cool.
[TheEnvious] ?
[W4RL0RD] So that was it.
[W4RL0RD] I hope you guys enjoed this lesson and learned something new.
[W4RL0RD] enjoyed*
[TheEnvious] Yep, good lesson πŸ™‚
[Anon_Blackcat01] thx W4RL0RD
[TrevorC] it was great
[W4RL0RD] Next lesson will be better for sure.
[TrevorC] Can i ask when is the next lesson?
[W4RL0RD] Anon_Blackcat01: Take this.
[Anon_Blackcat01] we need time to source new material before next lessons
[TheEnvious] what subject for next lesson ?
[Anon_Blackcat01] this was the last lesson
[Anon_Blackcat01] no more lessons for now
[TheEnvious] Ok, why ?
[Anon_Blackcat01] taking a break
[Anon_Blackcat01] we will return tho
[Anon_Blackcat01] with new lessons
[W4RL0RD] Even better.
[W4RL0RD] And stronger.
[W4RL0RD] And maybe a bit gayer.
[TheEnvious] x)
[TrevorC] :p
[TheEnvious] Ok, i hope we will have real gacking subject for next lessons πŸ˜›
[Aspire] i liked the lesson W4RL0RD
[Aspire] i like python
[Aspire] tanks
[W4RL0RD] Well i want to continue Python lessons.
[W4RL0RD] No problem Aspire.
[W4RL0RD] But i have not enough time.
[Aspire] dont worry
[W4RL0RD] Maybe if it started in 12pm GMT i would.
[Aspire] bye
[Mink] thanks W4RL0RD
[TrevorC] goodbye everyone!

(Visited 295 times, 1 visits today)

Comments are closed.

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.