darshna

I am reading the book Linux for you and me, and some of the commands I got to know and it's work!! Gnome Terminal Here in this terminal, we write the commands.

For example: [darshna@localhost~]

Here Darshna is the username, localhost is the hostname and this symbol `#~ is the directory name.

Following some commands are: * date command= tells us about current time and date in IST(Indian standard time) * cal command= displays the default present calendar. * whoami command= tells which user account you are using in this system. * id command=displays real user id. * pwd comma= helps to find the absolute path of the current directory. * cd command= this command helps you to change your current directory.

#Did you know? We can assign multiple assignments in a single line.

For example:a,b = 10,20
a=10
b=20
You can use this method for swapping two numbers.
a,b=b,a
a=20
b=10

To understand how it works, we need to understand a datatype called tuple. We use a comma, to create the tuple; in the right-hand side we create the tuple(called tuple packing) and in the left-hand side we do tuple unpacking into a new tuple.

Let us take an example tp understnd more clearly.
data=("Darshna Das, West Bengal, Python")
name, state, language=data
name=Darshna Das
state=West Bengal
language=Python

Formatting a string Let us now see different methods to format string. .format method

name="Darshna"
language="Python"
msg="{0} loves {1}". .format(name,language)
print(msg)
Darshna loves Python.

Interesting fact In Python 3.6 a new way to do string formatting introduces a new concept called f-string.

name=Darshna
lanuguage=Python
msg=f"{name} loves {language}
print(msg)
Darshna loves Python.

f-strings provide a simple and readable way to embed Python expressions in a string.

In continuation with the last blog, we now proceed with the following topic.

Variables and Datatype Following identifiers are used as reserved words, or keywords of the language, and cannot be used as ordinary identifiers. They must be typed exactly as written here:

false                   class              finally

is                         return            

none                    continue        for

lambda                  try             

true                       def                  from

non-local              while

and                        del                   global

not                        with

as                           elif                  if

or                           yield

assert                     else                 import

pass

break                     except               in

raise

In Python, we don't specify what kind of data we are going to put in a variable. So, we can directly write abc=1 and abc will become integer datatype. If we write abc= 1.0 abc will become of floating type.

Eg:-
a= 13
b=23
a+b
36

From the given example we understand that to declare a variable in Python we just need to type the name and the value. Python can also manipulate strings, they can be enclosed in single quotes or double-quotes.

Reading input from keyboard Generally, the real-life Python codes do not need to read input from the keyboard. In Python, we use an input function to do input(“string to show”); this will return a string as output.

Let us write a program to read a number from the keyboard and check if it is less than 100 or not.

testhundred.py
#!/usr/bin/env python3
number=int(input("Enter an integer:"))
if number<100:
print("Your no. is smaller than 100")
else:
print("Your number is greater than 100")

output:
$ ./testhundered.py
Enter an integer: 13
Your number is smaller than 100.
$ ./testhunderd.py
Enter an integer: 123
Your number is greater than 100.

This is the continuation of the Python learning series from the book Python for you and me.

Modules – These are Python files that contain different function definitions or variables that can be reused. These files are always ended with the .py extension.

For writing any language you need an editor, similarly here we use mu editor which was developed by Nicholas Tollervey. For installation, the total download size is around 150MB. We can open the editor from the command line type mu in the terminal. Give the following command line, type mu in the terminal

python3 -m mu

Executing Code – Write your code you want to execute and save it. – Use a proper file name. ( end it with .py) – Click on the run button to execute the code. – If you want to a REPL, then click REPL button.

NOTE: Do not give any unnecessary space in the file name, use _ if required, for an example download_photos.py

I have just started with Python, from the book Python For you and me!

Some basic guidelines I have jotted down. The first program to print the “Hello World !”

print ("Hello World!") = Hello World !

While writing this above code, we write it into a source file. We can use any text editor. For example:

#!/usr/bin/env python
print ("Hello World!")

On the first line, we use (#!), which is called she-bang. In python, this indicates that it should be running the code. The lines of text in python is called “strings”.

Whitespace at the beginning of a line is known as indentation, but if we use the wrong indentation it shows an error.

Basic Rules For Indentation!

  • Use 4 spaces for indentation.
  • Never mix tabs and spaces.
  • One blank line between functions.
  • Two blank lines between classes.

Always give a space after # and then start writing commands.

I learned about open-source when I got involved in a community called #dgplug, the full form states that Durgapur (Dgp), Linux(l), user's(u), group(g). Here we, folks are taught about open source systems and how can we work on Linux and other open-source software. Now for working on Linux, you need to install another operating system, before I always used Windows. I got involved in the channel's conversation but until an, unless if you aren't doing it practically on your computer or laptop its not helpful. Then I was suggested by some folks in the channel that I can dual boot my system, which means having two operating systems on the same computer. It was quite tricky for me because I had to see both the pros and cons, as I don't have a very advanced computer, just having RAM of 2GB might make things slower. but I had to take a step because I had to learn about Linux. Unfortunately, my computer broke down and I wasn't able to work on it for at least a week or two. But I asked my repairer if he can dual boot it too while repairing it. Initially, he too didn't know much about installing fedora and was not sure if my computer will work after this, but luckily things got better and successfully he installed Fedora 20( i need to upgrade this, this a very old version).

I was scrolling my social media account (fb) and suddenly saw a post of a song of a very old cartoon NODDY! Oh my god! It instantly lifted my mood and made me smile, these 90's cartoons back then really made our childhood so memorable. We grew up seeing these and back then I felt that the world was too simple, colorful, bright and easy. That's why I always wanted to grow up so fast and wanted to be out and wander freely like those cartoon characters. But sadly growing up is not at all fun, we have to grow up and work ourselves but somewhere I miss that innocence among people which we shared while being children, people are now self-centered. I often participated in singing competitions and did not thought what people will think if I made a mistake. But growing up really makes self-conscious again, about being judged. Still, here it is the life cycle goes like this, being responsible and taking care of your parents and hence, it continues! But why are people now selfish, dirty games and politics and yet we deal with it and move on.

Following my previous blog you all know that I am from Electronics and Communication Department and why I chose that. Coming from a family that have high expectations from me(and I don't blame them) I always wondered that if I come into this profession I'll be having a good and stable job and contribute to society and all good things you know! These I thought before I got into engineering, I really loved my stream truly, I thought that this will be exciting and interesting(though all subjects didn't interested me rather got very boring)as days passed and I got into the world of computers it was not a choice that I made it because I wanted it but because I had to, electronics is nothing without software so I had to but slowly its taking my interest and it is, quite fascinating how all these soft wares, work how do they work and how can we make them work (though i don't have so much knowledge about it,just overall analysis). I learnt that there are not too many exciting and open opportunities for my stream of core jobs, and at last we all have to shift into masses into software world, and I am loving it, yes learning about these new stuffs. But if I change my stream from ECE to software is it fine? Like will it hamper anything right? can I do that? can I switch to softwares completely? but on the other hand i have keep reading my stuff too to get that required points and all that stuff! Switching into softwares I found everything new and exciting and also if I am not an expert here there is no use in electronics, but I don't want to go into electronics anymore, too lengthy process plus the field that I had an interest doesn't have any future here so I don't want to process into it, I just want to keep learning about computers and want to be a part of it, it has logic,it makes sense and sadly now my subjects they keep confusing me and have to keep in mind lots and lots of things, I don't have such big brains to hold so much. I too want to be good coder at last!

So,this is where I start my blog writing and thanks to my seniors from dgplug, for pulling me out and giving me this confidence to start blogging. I always wanted to write but thought that I need a perfect topic to write,but this is what I learned, it's me my voice not some article publishing. I was never fixed to one place, my father because of his job had to move from places to places, I lived in Mysore for two and a half years and then moved to Udaipur, Rajasthan. At 2008 I finally came to Durgapur and started my schooling. And ended up my higher secondary schooling from Bidhan Chandra Institution For Girls And then I got admitted to Dr.B.C.Roy Engineering College in Electronics and Communication Engineering. Initially I was adamant that I would stay away from computers and programming language but coincidentally I found that I stand nowhere without computer knowledge. So this is it for now and this blogging is not stopping now.