Python lesson2 for beginner

Python lesson2 for beginner

we will see the some more python codes in the following sections:

we will discuss on following topics:

  • Python lists

A list in Python is like a container that holds multiple items. These items can be numbers, words, or anything you want. Lists are created using square brackets [], and items inside the list are separated by commas.

  • Range in for loops

In Python, the range function is often used with for loops to generate a sequence of numbers. It’s useful when you want to repeat a task a specific number of times.

Here’s how you can use range:

for number in range(5):
   print(number)

This loop will print numbers from 0 to 4 because range(5) generates a sequence starting from 0 and ending at one less than the specified number (5-1 = 4).

You can also use range to specify a starting number and an ending number:

for number in range(2, 6): 
   print(number)

This loop will print numbers from 2 to 5.

  • strings and string manipulation

In Python, strings are used to represent text. You can create strings using single or double quotes: More detailed codes are explained in the embedded python codes in below section.

  • list operations

You can perform various operations on lists in Python, such as: adding, subtracting, finding and other list operations.

  • String operations

String operations in Python allow you to manipulate and work with text effectively. Some common string operations include concatenating, finding length of string, finding patterns, changing cases, splitting stings etc.,

Introducing to basic python codes.

The Following session shows the basic pythons codes which has been run by Jupyter IDE. Jupyter is a python notebook where we can execute the codes. Please click on the link above to see the code details in your computer. Google colab provides this feature in the web similar to the Jupyter notebook. You can connect these codes in Google colab and run the codes live and see the results. Google colab may not work in phones, preferred to use computer or laptop. Please scroll through the embedded page to see the complete content.

The python code block is embedded here in the below section. please scroll through the embedded page to see the complete content.

After completing these codes, go through the next topic :python-strings-list-objects

Was this article helpful?
YesNo

1 thought on “Python lesson2 for beginner”

Leave a Comment