googleAd

Python for Beginners - Learn Python Without IDE - 2 (Variables)

 Python beginner tutorial encourages you to learn by doing. Follow along this Python course to get started. This is Part 2 of the python full course for beginners which just gets you started by showing how to install python on your machine and write your very first program. Subsequent parts will follow shortly.

I have chosen not to use any python specific IDE (Integrated Development Environment) in this course. IDEs tend to do lots of autocomplete which hinders learning. As you get familiar with python basics, programming concepts and get comfortable writing python programs without an IDE, you will find IDEs more productive later. As a python beginner, start from the scratch. I value all feedbacks. If you liked this method of teaching or have any constructive criticism, please share that in the comments. Please subscribe to be notified of the next part of the course.

TABLE OF CONTENTS 0:00:00 Sample Programs for Mathematical operations 0:01:53 Command Prompt Tip 0:02:14 Program Data and Useful Output 0:02:43 Handling Multi-step processing and Hard-coding Elimination 0:03:08 Need for a Placeholder 0:03:39 What is a Variable? 0:03:48 Sample Programs Using Variables 0:06:35 Math operations using Variables 0:07:44 Sting concatenation using Variables 0:08:47 One last math operation Variables - Division with Decimal




Transcript:
Let us create a program that can do some mathematical operations. For that I'm going back to my folder where I was creating my Python Programs. And I will create a new program in notepad. So, I'll open notepad and I'll give a name math.py. Python programs will have an extension of dot py. So let me open this and I'll make use of the same function which is print and as mentioned before if you are calling a function, it needs to be followed by a parenthesis. The last time, we gave a string as an argument. The string was "hello world". This time we are not going to be passing a string argument. Rather, we are going to pass a numeric argument. So let us try giving a number like 3. And let us see if the print function will be able to print a number. Let's save this and exit out of here. And let us execute this program. python math.py . It was able to print out number 3. So now let's open notepad again and what if instead of printing this number, I did some math operation like an addition. Let's try it. python ... and pass the program name which is... math.py and we got our result which is 7. Going back to our program, what if I did a subtraction; say 3 minus 4. Again execute the program, I got a -1. How about division? What if I gave 16/2? Let's execute the program. If you are not very familiar with the command prompt, doing a up arrow or down arrow will bring back your previous commands that you typed. So, I'm not retyping these things. I'm just using the up arrow to bring back my previous commands. Ok, I'm going to execute this program. so we got 8.0 which is correct. So, a program consumes data, does some processing on it and creates a more useful output. In our examples, the data for our programs were hardcoded directly in the programs. However, in real world applications, the data comes from outside of the program. The data could come from an user input, or it could be coming from internet, or it could come from any external devices. Or it could very well be a file on your system. The operations performed on the data is not a simple addition of number. Data typically undergoes complex set of operations to produce the desired output. The output of the data processed in the first step is passed on to the second step and the output from the 2nd step will be passed on to the 3rd step and so on. It so appears, that the program needs some place holder to store these intermediate results from one step so that it can pass them on to the next step. To rerun our program with different set of inputs, we need to avoid hard-codings in the program. Again, we need a place holder that can source the input data from the outside world and pass on to the operational steps. This place holder is called a Variable. Variable is just a name given to a piece of memory that can be used as a temporary place holder for your data. Let us create a new program where we can make use of a variable. So, let me name this program variable.py. How do I define a variable ? It is very simple in python. Unlike other languages, where you need to first declare a variable and then make use of it later, in python you can create a variable and directly assign a value. For example, I can create a variable like welcomeString. And I can assign it to a value like "Hello World". Or I can put like a = 2 , b = 3 . All these are variables. welcomeString is a variable. and you assigned a value "Hello World". Here a is again is a variable and we assigned a value 2. b we assigned a value 3. b is a variable. Similarly you can define c and you can give a decimal value like 8.4. c is a variable again. Now that we have assigned a value to a variable, let us print them out. print ... And how do I print the value in a variable? In the argument of the print function, you just give the variable name. welcomeString. And I want to print the values, the variables a, b and c hold as well. So, let me print them up by providing the variable names within the parenthesis of the print function. print(a)... print(b) ...print(c). Ok, let's save this and execute it. python variable.py. We can see that we were able to print the value those variables were holding. Let us do something more with the variables. So far we have just printed the values of the variables. Now let us try doing some mathematical operations with these variables. In the last example, we added numbers like 3 and 4 by directly using the values but here we are going to make use of the variables that hold these values. So instead of just adding the 2 numbers, here let us add the variables like b and c. How about we assign the sum of these 2 variables to another variable say d ? d = b + c. It is not just enough that we assign the sum of b and c to d, but also to print it out. So let us print(d). So, let's see if this works. As you can see, we added the variables that contain the value 3 and 8.4 and we got the result of d which is now 11.4 (that is the sum of 8.4 and 3) . Let's go back to our program. How about some string functions? So, we know we have a variable called, welcomeString that holds the value 'Hello World'. How about we add one more variable: name and let it have the value 'Shan' . And now we want to concatenate these 2 strings. 'Hello World' and 'Shan' . How do we do that? Let us define another string: newString and let us try using the same plus operator and see if the concatenation works. welcomeSting + name and let us print this newString. Hope you are able to follow this. Let us execute this program. It was able to concatenate "Hello World" and "Shan" together. Let us go back to our program. Let us define another variable e which can be a division of b and c. b divided by c. the value of b is 3. the value of c is 8.4 . so 3 by 8.4 . Let's see what the answer is. It is 0.35. So we got our value here.

Python for Beginners - Learn Python Now Without IDE

Python Tutorial for beginners encourages you to learn by doing. Follow along this Python course to get started. This is Part 1 of the python full course for beginners which just gets you started by showing how to install python on your machine and write your very first program. Subsequent parts will follow shortly. I have chosen not to use any python specific IDE (Integrated Development Environment) in this course. IDEs tend to do lots of autocomplete which hinders learning. As you get familiar with python basics, programming concepts and get comfortable writing python programs without an IDE, you will find IDEs more productive later. As a python beginner, start from the scratch. I value all feedbacks. If you liked this method of teaching or have any constructive criticism, please share that in the comments. Please subscribe to be notified of the next part of the course.

 Welcome to the Beginner Series in learning Python. Learning Python will be one of the best decisions you have ever made. Python is a very powerful, yet simple to use programming language. You can create solutions to very complex problems with very few lines of code. Also the syntax of python is very readable and it is easier to maintain. Many top companies use Python because it improves their productivity. It is also a very portable language, meaning you can deploy it easily in multiple platforms like Windows, Linux, Mac or any of the mobile devices. For all these reasons, python is one of the most popular programming languages in the world. Without further ado, let's get started. The first step to learning python is to have a python environment where you can write and execute your python code. This environment can be in your laptop or your computer or it can be online. I recommend you setting it up on your machine first where you can write and execute your code. 

Below is my free course on python. Enjoy!


#pythonBeginner 


Installing Raspberry Pi from Canakit

 Raspberry Pi is a wonderful mini computer that consumes less power and can be a very powerful machine for a variety of projects like running your own vpn server or running a web server, media server or game server. Raspberry Pi has become more and more powerful over the years. It is extremely tiny making it very portable. We will see how to setup a Raspberry Pi device. I bought mine from Canakit. 

After burning my first Pi after heavily loading it with accessories, I decided to be a bit careful on my 2nd device. On my first Pi, I had only bought the board and I used my own power cord. This time I bought all the necessary accessaries from Canakit, including pre-installed Raspian OS, a case, heat sink, a fan and a power cord. 

Mine is a 8 GB Ram and I got a 128 GB sd card which comes with pre-installed Raspian OS. It was very easy to install the Raspberry pi board on to the case. Also installing the fans, heat sinks and connecting with the power cord was super easy. 

Below is a video demonstrating the setup. 



Kansas City Zoo - Review

 A few days back we had gone to the Kansas City Zoo, a trip that was very worthy of our time and money. 

My 4 year old enjoyed identifying all the animals she had seen on her books and Tv. This zoo is bigger than the Topeka zoo and even the St. Louis zoo. It is 202 acres in size and houses around 1700 animals; so you can plan your entire day for this zoo. 

I was really surprised to see some Polar Bear, Jelly Fish and Penguins in this zoo. However Polar bear wouldn't be bleach-white you would have seen on movies. I had thought Polar bears can live only in the Arctic and the Penguins can live only in the Antarctic. Kansas City Zoo proved it can live anywhere with the right temperature settings. 




The Penguins were in a temperature controlled glass rooms which had both snow in one section and a large swimming area in the other. 


I hadn't seen a Jelly fish so up close before, so it was a visual treat.


                                       


 The Sea Lions demonstrated some acrobatics while the their coach narrated their life story. See video below



The zoo is divided into sections where it houses animals from different geographical locations. Australia and Africa the popular ones. You can either walk across the zoo or use one of their trams. We bought a platinum pass that gave access to their African Tram, African Sky Safari, Carousel of Endangered Species, KC Zoo Railroad and the Kenyan Cruise.



African Sky Safari:


View of the Zebras from Sky Safari


Feeding the Goats in Kansas City Zoo



The Tiger:



You can buy tickets online for both admission and the rides on kansas city zoo website - https://www.kansascityzoo.org/





8 Reasons Why You Should Learn Python?

Here are 8 reasons why you should consider leaning Python irrespective of whether you have programming background of not. 

1. Language of the future:
You have heard the name of this programming language not just because it is a hot cake today,  but it will be for years to come.  Artificial intelligence and machine learning programs are written on python as it is easy to develop with and readable. So you will be learning a technology that will be in use for years to come.
 
2. Great career opportunities:
Many top companies use python and are in the constant lookout for people with python among other skills.  Knowing this language increases your probability to get selected in these companies. 

3. Quickly develop POCs:
Even if your company doesn't use python,  you can still use it to quickly develop proof of concepts to ensure your algorithm will work. 

4. Automate your manual tasks:
Often you will come across manual tasks that are repetitive in nature eating much of your time. Having knowledge in python will enable you to quickly automate those tasks and save your much valued time. 

5. Easily portable:
Develop your software and package it in one machine and deploy in any machine and you can expect it to work the same way in all machines.

6. Easy to learn:
Python is one of the easiest languages to learn.  It is simple and very readable.

7. Powerful: 
Python is a very powerful language meaning you can achieve complex tasks with very few lines of code.  This is achieved with many libraries that can be easily imported in your code. 

8. Easy to maintain:
Maintenence is one important aspect to consider when choosing any technology. While the developer may know how the code works, the support personnel should find it easy to maintain it and add functionalities. Since the number of lines of code in python is typically lesser and the code is very readable,  it makes it easier to understand what the program does and how it works. 





Review of our stay in "The Westin Hotel at Crown Center" in Kansas City

 We made a last minute plan before memorial day to visit Kansas City Zoo and stay overnight in kansas city and visit places in Crown Center area. 

The zoo is really around 1 hour 15 minutes from Topeka. Hence this stay wasn't really necessary but thought it might be very tiring after a day's visit in the zoo. Also, since we planned to explore areas near Crown Center, we thought it may be better to stay nearby. 

We explored hotels very close to Crown Center and we came across 'The Westin Hotel'  which was within the Crown Center itself. 

Having worked for Hallmark Card as our client a decade back, I knew the Crown Center may be something my 4 year kid might enjoy. 

The hotel was very pricey around 300+ USD (incl. of taxes) per day, partly may be because we chose hotel last minute. We wanted to see what experience this pricey hotel might provide us. 

For one, it was the best location - right within the Crown Center, you can walk to any attraction within Crown Center area. The best of all, you can use 'The Link' which is a climate controlled Glass bridge running across the streets connecting different buildings in the Crown Center area. The Crown Center itself is a mall. Right across the street you have Lego Land and Sea Life which the children will enjoy. 

You can also walk to Union Station via 'The Link' where you have 'Science City' and Planetarium.

The view from our hotel was great. You could see the War memorial from there. 

The next is cleanliness. The hotel, its corridors, the room the bath - everything was impeccable. So, the hotel scores in that. 

However, we didn't like the below aspects. There was no microwave oven in the hotel. For this price, I would have expected it to have provided a hotel with microwave. I should have checked what facilities were available at the time of booking. But since I was booking at last minute, I didn't really research much upfront. I just assumed these things are a given, especially when charged a 300 usd. 

Second, the parking. It is not free. So far in the hotels we had stayed so far, we never had to pay for a parking. Here Parking is extra - $14 per day. I just think that is unreasonable to charge hotel guest for parking. 

The unbelievable part was that there was no free WIFI either. You needed to be in some paid membership to get a free wifi or pay like $20 for some limited data. If video streaming or calls are going to be used, that is still extra. What world they are in - charging for the internet in a hotel?

Not all the rooms provide complimentary breakfast. Ours had. The ones didn't have also weren't like cheap rooms or anything. they are also above 220 USD/day. On our day, the dining room was just blocked for some 'special people'. So, it meant, we could grab the breakfast from there but had to bring it to the adjacent dining area supposedly meant for Starbucks. There weren't much options in food for us. We had some scrambled eggs and a bread. 

For dinner, we bought aVeggie Cheese Pizza from Spin Pizza (within the Crown Center) which was good. 

If you just want to be within Crown Center and want a super clean room, you can consider this hotel but it is very pricey for the facilities it provides. If you get a deal on the price, you can definitely check this out. but note you still need to pay for parking and internet and don't have an option to microwave. 





Question for the day: What flower is this?




 Identity the plant.  Leave a comment. 





Answer: This is the onion plant when it flowers. The green part is called the green onions.

Topeka Public Library

I have been interested in libraries since college days. I wouldn't say I read a lots of books, but I did take the time to enjoy reading select technical books especially those of foreign authors. Now while in a foreign country it was just natural to explore the library here. Topeka, capital of Kansas state, USA boasts a wonderful library. 

Topeka public library is more than just lending books. They are about developing communities. They have lots of programs that encourage kids and adults to visit the library, read books, learn a skill and even help them do a project. 

If you don't have the time to read books in the library, you can borrow a generous number of books for a generous number of days and they do automatic renewals a number of times if you missed to return it or renew by yourself. They even let you order the books online and you can just pick them up at the parking lot where they deliver your books at your car though I don't endorse that. The best you can do for yourself and your library is by visiting it and making use of the various resources they have for you and your kids. 

Not interested in books, rather prefer watching a movie? no worries. The library has a section dedicated for movies. Not just a handful of movies for namesake. they have an huge collection of movies in various genres. If you aren't just keen on the the movie released last week, i don't know why anyone should buy or rent a movie outside. They have international movie section also and I have seen many Indian movies too including Tamil movies of Manirathnam, Dhanush, Rajnikanth and more. You have a good collection of all famous TV series. 

You still don't have the time to visit the library or drive to the library for a pickup? they can deliver it at your neighborhood. The mobile library of theirs have scheduled visits to all the neighborhoods in Topeka and people can order online and get it delivered closer to home. they can return the books at multiple drop boxes near your neighborhood. 

The library also has conference rooms equipped with TV screens and computers. If you want to meet as a team, these are best places to block some time and work on a project. The digital collection of the libraries are enormous too. you can browse them online via Hoopla or OneDrive or use one of their many computers on the premises. 

They also have a makerspace where you can do 3d printing or build your electronic project. Interested in arts, they have a section for various art forms not only equipped with books, but actual kits that you can take home and try out. Interested in learning knitting? Borrow their knitting kit which comes with the needles, instructions and some consumables like the threads (which you don't have to return). Interested in learning to bake? they have a kit for that too? Want to 3D print your project? They got it. they have regular 2d printers as well if you want to take a print of your documents and don't have a printer at home. 
Need a notary signature? Topeka library provides that for free whereas UPS or anywhere else the charge is 30 dollars +. 

They have a complete wing dedicated for kids. The library staff are extremely friendly and make sure you and your kids have a great time in the library. My 3 year old Varnikaa enjoys the kids section. This section has lots of books for kids of various ages. Your kids have seen Sesame street or Peppa Pig on Tv?, they got books on all that. They have a school bus setting in one spot which has some more books. You can also get some play kits which you can borrow and those have lots of consumables that you don't have to return (like finger puppets). There is an aquarium which Varnikaa loves very much. A huge dinosaur and some planets hanging from the roof. There is a small slide and some numbered mats to jump. She loves them all. 

The library serves the community in a way I haven't see any other library does (at least in India). The least you could do to support their efforts is to make use of them. Read a book, bring your kid to play in the kids play area, rent a movie, do a project, learn a skill or teach something you know. 

Last but not the least..were you paying to visit the zoo or the Children Discovery Center in Topeka. I recently learnt that you didn't have to if you were referred by the library. The library can give you a 'passport' which you can use at the zoo or the discovery center and get admitted free of charge. 

Aren't libraries like a temple in a way? They are quiet places - you can cut off from all distractions around you and do some peaceful time for yourself! 

Here is a video of the automated book return inside the library. 



Happy new Year

Wishing all my readers a happy new year! My resolution is to complete writing a book this year. What is yours? Leave a comment!

Python for Beginners | Chapter 8 | Conditions Explained

In this chapter we will learn how condition statements work in python.  If you are new in here, you may want to start from the beginning...