❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Python - Fundamentals

By: ABYS
16 July 2024 at 14:00

In here, I'm gonna tell you how to use variables in python. We shall see how to name a variable and assign values to them.

How to name a Variable ?

Firstly a variable is nothing but a reference to an object or value throughout the program. They act as reference to a memory where the value is stored.

There are certain rules to name them.

  • Must begin with a letter (a-z, A-Z) or an underscore (_).
  • After the first character, letters, digits (0-9), or underscores can be followed.
  • Variable names are case-sensitive. For ex, myName and myname are entirely different variables.
  • Should not use Python reserved words as variable names For ex: class, def, for, while.

So, in python the operator = is used for assigning values to variables.

# Assigning integer value
age = 18
print(age)

18

# Assigning string value
name = "Arif"
print(name)

Arif

# Assigning float value (float means decimal value)
height = 2.5
print(height)

2.5

# Assigning boolean value (rfrs to true/false)
is_student = True
print(is_student)

True

Varible Types

Python is a typed lang, we needn't declare the type of a variable when assigning a value to it. The type is inferred by its own.

name = "Abys"
print(name)
print(type(name))

Abys
<class 'str'>

or we can also define the type by,

name = "Abys"
type(name)

str

age = 18
type(age)

int

That's the basic.

I've been asked to complete some questions on my own, lemme discuss those with you guys.
It's much easier to learn right...?

1. Create a variable named name and assign your name to it. Then print the value of the variable.

name = "Abys"
print(name)
print(type(name))

Abys
<class 'str'>

2. Create a variable age and assign your age to it. Later, reassign the variable with a new value and print the new value.

age=17
print("Present age:",age)
age= 18
print(age)

Present age: 17
18

and here if we want the type;

print(type(age))
<class 'int'>

3. Assign the values 5, 10, and 15 to three variables a, b, and c in a single line. Print their values.

a,b,c = 5,10,15
print(a,b,c)

5 10 15

if we wanna add them we get,

print(a+b+c)

30

4. Swap the values of two variables x and y without using a third variable. Print their values before and after swapping.

x,y = 5,25
print(x,y)
print(x-y)
x,y = 25,5
print(x,y)
print(x-y)

5 25
-20
25 5
20

they've asked just to print the swapped values, it's me who did extra stuffs.

Before the next qn we ought to know what is constants...

What are Constants ?

In Python, constants are those values that are not meant to change. By convention, they are typically written in capital letters with underscores separating the words.
However, in python constants can also be changed.

5. Define constants PI with appropriate values and print them.

PI=3.14159
print(f"{PI:.3f}")

3.142

6. Write a program that calculates the area of a circle using the constant PI and a variable radius. Print the area.

PI=3.14
radius=7
r=radius
area=PI*r**2 # r**2 refers to r pow 2
print("Area of circle is",area)

Area of circle is 153.86

7. Define constants for the length and width of a rectangle. Calculate and print the area.

L,B = 5,15
area = L*B
print("Area of rect is ",area)

Area of rect is  75

These were the qns I worked on. Hope it is clear.
Sorry, if I'm ain't clear enough.., as I've just started blogging I may make mistakes.
Definitely will improve myself.
Thank you, All...

Python - First Week

By: Suresh S
11 July 2024 at 21:23

Python is taught online in Tamil without any cost. The only expectation from them is to create a blog and write our understanding after learning. Hence started writing the blog.

  • Started Learning python through Kaniyam. Got to know about two Tamil people Syed and Srini. Classes will be for Monday to Wednesday at 7pm to 8pm

  • WhatsApp group was created and 3 classes completed. Agenda for every class is clear. During the class Zoom Recording and YouTube Live both were made which is useful for Checking it again.

https://kaniyam.com/python-course-2024/
https://parottasalna.com/python-development/

I have already installed Python and VS code available in my laptop. Find little difficult to understand running the sample program via Terminal and from Vscode. After few tries it is little clear now. So environment is made available for the class.

Lot of free ebooks are available to learn python other than youtube videos. Recommended book links are as below

Day 1: Meet and Greet:

Agenda:

  1. Why Python ?
  2. Course Syllabus
  3. Python Installation - Windows, Linux
  4. Collab Notebook
  5. Where to see updates & recordings.
  6. Where to ask questions ?
  7. Our Expectations
  8. Basic Print Command
  9. About FOSS, FOSS Communities.

Post session, the below information is shared

Youtube Recording:
Part 1: https://www.youtube.com/live/rcJRkt3odlw?si=SZGCr6aBVwSQII0g
Part 2: https://www.youtube.com/live/xBpXOkyoFD8?si=Z89W5VAtLnkUpFHH

How to create a blog:
https://www.youtube.com/watch?v=pkp8WK9ub4o

Google Form to submit your blog url:
https://docs.google.com/forms/d/e/1FAIpQLSdiJ3qQ-37YSi2VnTFpgVIJL0iE9mxveKHA3kFnwVAmhJooMg/viewform?usp=sf_link

Whatsapp Group Links:
Group 1: https://chat.whatsapp.com/DcfvtLP0y6S0iUkjCJLcH7
Group 2: https://chat.whatsapp.com/ErBIxb1lQfs7mNRo33c4Vc
Group 3: https://chat.whatsapp.com/ETxQ9WVCXkp5TYmY22wLaC

Tamil Linux Forum Link: (Ask Your Queries here)
https://forums.tamillinuxcommunity.org/

Community Links
https://forums.tamillinuxcommunity.org/t/gather-all-the-foss-group-in-tamil-nadu/1387

Python Download Link:
https://www.python.org/downloads/
Google Colab Link:
https://colab.research.google.com/

Day 2: Python Print

Agenda:

  1. 10 min discussion on previous class
  2. Basic print statement
  3. Multiple prints
  4. separator
  5. concatenating strings
  6. escape sequences
  7. raw string
  8. printing quotes inside strings.
  9. printing numbers
  10. multiline strings
  11. string multiplication
  12. combining int and str in printing
  13. .format
  14. f-strings

Concepts are understood. Important links are

Youtube Recording:
Session: https://www.youtube.com/watch?v=zr3skBHzbAI&list=PLiutOxBS1Mizte0ehfMrRKHSIQcCImwHL&index=4&pp=gAQBiAQB
Q/A: https://www.youtube.com/watch?v=OWjW7GBMND4&list=PLiutOxBS1Mizte0ehfMrRKHSIQcCImwHL&index=5&pp=gAQBiAQB
Blog: https://parottasalna.com/2024/07/05/python-fundamentals-the-print/
Quiz: https://docs.google.com/forms/d/e/1FAIpQLSeW7dGCYrvPXBK7llexbwa_yImFQWFiHHE4c4ATOk-NwJWxIw/viewform?usp=sf_link
Task: https://parottasalna.com/2024/07/04/task-1-python-print-exercises/
Playlist: https://www.youtube.com/playlist?list=PLiutOxBS1Mizte0ehfMrRKHSIQcCImwHL
Colab Notebook: https://colab.research.google.com/drive/1Uu9btRd_U0i3-PRfZwlR2QalJRp0DbBK?usp=sharing
Infographics: https://parottasalna.com/wp-content/uploads/2024/07/print-method.pdf

Byte of Python book is recommended. The link is'''

https://python.swaroopch.com/
https://www.tutorialspoint.com/python/index.htm
https://python.swaroopch.com/
https://pymbook.readthedocs.io/

'''

Day 3: Data types Variables and constants
Agenda:

  1. Discussion on print quiz.
  2. Numeric Types (int, float, complex)
  3. Text Type (strings)
  4. Boolean Type (bool)
  5. None Type (None)
  6. How to check a data type ?
  7. What is a variable ?
  8. How to define it
  9. valid, invalid variables
  10. assigning values
  11. multiple assignment
  12. unpacking
  13. variable types
  14. Constants

Details shared
Print Quiz Solutions Video: https://youtu.be/JzFLSZySbRI
Print Task Solutions: https://youtu.be/k6pwbOZtQ30

Variables Datatypes & Constants:
Session: https://youtube.com/live/5G0PoJofxXk?feature=share
Q/A: https://youtube.com/live/9cJDqHwQG5k?feature=share
Blog: https://parottasalna.com/2024/07/07/python-fundamentals-constants-variables-and-data-types/
Quiz: https://docs.google.com/forms/d/e/1FAIpQLSezKyjHkKlg4Qo8juWqviZkasyWOcAcEcBzK_NsBwGYG3WAvg/viewform?usp=sf_link
Task: https://parottasalna.com/2024/07/07/task-2-constants-and-variables/
Playlist: https://www.youtube.com/playlist?list=PLiutOxBS1Mizte0ehfMrRKHSIQcCImwHL
Infographics: https://parottasalna.com/wp-content/uploads/2024/07/variables-constants-and-data-types-in-python.pdf

There was a Q&A session planned by Srini and Syed today as there are many participants(11.07.2024 - Thursday)

I told them that I will create a blog this weekend. Srini objected and said that postponing the activity will keep that delayed. Hence today I started writing my first blog.

For teaching Kids, below websites can be checked

Other important links:

I have asked two questions today.

  1. Website link to teach kids?
  2. To know in detail about print function(like hovering over VSCODE on print provides detail) what I have to do?
  3. For the above I have to add some addons. those are Python and Pylance
  4. During the conversation Pandas also came which is a library for Excel data processing.

Also there was some interesting questions came about AI training using Python. It seems like with the available data, next prediction will happen like Regression LinearGraph.To know more about AI, We need to study the Book from Kaniyam

AI Libraries

  • Scifikit
  • Tensorflow
  • pytorch

To do:

  1. Go through the link or search on adding python, Pylance library to VScode
  2. Explore Pandas with the Ebook
  3. Read Byte of python till date

Python_In_Tamil-001

8 July 2024 at 17:06

Dear All,
I am Govindarajan from Thanjavur. I teach Basic Python through OnLine. I am a PCEP and PCAP.
Ok, let us start learning Basic Python.

  1. Install python from python.org as per your computer system.

  2. In windows, in the search bar, type cmd, cmd page will get opened. Write python at the cursor location and press Enter. If you see Python with the version number of the python, then it is confirmed that python is installed in your system. If not, go to the point number 1 above.

  3. Then, in the search bar, type IDLE. Click on IDLE with right side mouse and click Run as administrator. you will see a new window titled as IDLE Shell python version number. This window is called as Shell window or Console window.

  4. In the shell window, click File => New File. Another window with a title as untitled will open. This window is called as Editor window. we will write all our codes/program in this Editor window. It will be saved as python file(.py extension).

  5. Type ('Hello World') with a file name as BP001, save it(Ctrl + s), click Run, click Run Module F5 (or Fn + F5), the code will get executed and you will see Hello World in your Shell Window.

  6. Great !!!. You have successfully completed your first program in Python. Congratulations.

Let us meet tomorrow in 'Python_In_Tamil-002'.

Thanks and Regards.
Govi.
https://www.youtube.com/@Python_In_Tamil

❌
❌