Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 257 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Tutorial, Beginners | 2 |

#1
[Image: attachment-0001.png]
[Image: tqpbe.png]

Hello, and welcome AF,

So, hopefully you've watched my other Python Basic tutorial, and if not please take a look:

[To see links please register here]


So, shall we begin for today? I guess so.

So, today we will work with the different types of 'lists'. This is a basic thing, but it can be used for more than you may think :wink:

But first, I will show you some IDLE things you need to know. So, youve been working in the Python Shell right? Well, you can only create small programs. Which, in some cases doesnt even is worth your time saving. So, how do you create more advanced programs?
Well, thats easy!

Just click file > New Window, and Woala!
There you go, more space to work, and it's easier to work in. Now, im not saying it's always better to work in this since you need to save every time you are about to run the application youre about to make. Sometimes, if you just want to do some testing just use the shell, its more clean and easy for TESTING in my opinion.

So right now, you have the second window open, where you can write code, and save your creations. One note when you are saving, you have to do as following:

File > Save/Save-as > Choose a name and end it with either .py or .pyw and select "Python files (*.py,.*pyw)" as the file format. Save it where you want and just simply double click it :smile:, it will run as a CMD window as default, executing your code.

So, lets do some coding for you to get the picture.

Btw, here's a picture.

[To see links please register here]


So, time to do some basic coding aight?

What we are about to do is a program where you will have to enter your first and second name and we will be adding those together, lets begin.

First off, New Window. Well, here's the code: (Please, for your own good. Look at it then write it, do not copy)

fname = raw_input("Enter your first name: ")

Then, everything you will enter in this input statement will have the variable "fname" (firstname)

Second, you have to enter a new variable to assign to, wich should be?

Youre right, your last name.

lname = raw_input("Enter your last name please: ")

This is the same as the upper one, whatever you write in the input, lname will get assigned to.

now comes the 'tricky' part of this section, adding them together. We will basically adding them together and print them out as "Dean Martin" for an example.

So, once again here's the code. (Do not copy, for your own good)

print fname + lname

And you will get it printed :smile:

Note:
In Python 3.x raw_input() was renamed to input(). That is, the new input() function reads a line from sys.stdin and returns it without the trailing newline. It raises EOFError if the input is terminated prematurely (e.g. by pressing Ctrl+D). To get the old behavior of input(), use eval(input()).








So, time to get to the actual tutorial or? Haha, yea :smile:

The big thing for today was, and is different types of lists, such as original 'lists' tuples and so on, i will be concluding the differences between them all, and give some suggestions what you can use them for, so lets begin!

(For this, i recommend you to be working in the Python shell, since there's going to be a lot of executions)

How do we create a list? With one basic command:

name = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Now, we've created a list named: 'name' and it has 10 different values we can work with.
Just before we start to take a look, Python starts to read from the number 0 (zero) so if you executes this command:

name [0]

It will show the first one, number one.

and if command:

name [5]

is executed, number 6 will be showed, and so on.

Here's a list of a few different 'list-editing' commands which can be to good use:


list.append(x)

Add an item to the end of the list.

list.extend(L)

Extend the list by appending all the items in the given list; equivalent to a[len(a):] = L.

list.insert(i, x)

Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x).

list.remove(x)

Remove the first item from the list whose value is x. It is an error if there is no such item.

list.pop([i])

Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)

list.index(x)

Return the index in the list of the first item whose value is x. It is an error if there is no such item.

list.count(x)

Return the number of times x appears in the list.

list.sort()

Sort the items of the list, in place.

list.reverse()

Reverse the elements of the list, in place.

You can find more commands on the web.

If you want more list specific tutorials please check out the following site:

[To see links please register here]


Well, i would like to recommend you all to repeat what we've done and i will be back. I will now give you a list of different Python Ebooks, for you to learn even more and advance in Python, NONE of these are written by me. So all credits goes to the authors!

It's a variety of both advanced and beginner tutorials, explanations, and i hope you'll be enjoying them.

Download link:

[To see links please register here]


Please, stay tuned for next time and i will be posting more Python projects for you guys to look at!

Have a nice day
Reply

#2
Nice tutorial! Are you going to post these consistently?
Reply

#3
Hey man, thanks for these tutorials. They're very helpful, you have me interested in Python - I want to add it to the list of languages I know.

Thanks!
Reply

#4
Im really thankful for your feedback, thanks :smile:

Well, yes i think i'll continue. :smile:, I will make more Python basics tutorials, and if you guys what have anything specific told please send me a Pm
Reply

#5
I'm stuck on the list functions.
Like the append and stuff.
Help?
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through