Skip to main content

Command Palette

Search for a command to run...

Basics of Python-4

Published
2 min read
Basics of Python-4
P

Hello, I'm Priya Chakraborty, a dedicated B.Tech student in Electrical Engineering at Siliguri Institute Of Technology. I'm an enthusiastic learner, constantly seeking to expand my skill set and knowledge base. With a solid foundation in programming languages such as C, R, Python, and MySQL, I'm poised to tackle complex technical challenges.

But my passions extend beyond the realm of engineering. I'm also an aspiring content writer, driven by a curiosity to communicate ideas, both technical and non-technical, in a way that captivates and educates.

My journey is defined by a relentless pursuit of self-improvement, coupled with strong communication skills. I believe in the power of continuous learning and the importance of sharing knowledge.

Day 4

List :

Previously I have discussed that,

A list is a sequential data type

  1. An ordered collection of data

  2. It is mutable.

  3. It's an abstract data type.

Let's solve a few problems on the list :

  1. Write a python program to reverse a list
l=[34,76,23,11]
print(l[::-1])

output:

this is the easiest way to solve the reverse list by using the slicing operator.

  1. Write a python program to find out the length of the list
l=[3,6,3,4]
print(len(l))

output :

These are the basic code that I have solved by listing, using keywords.

  1. Write a Python program to print all negative numbers in a range.
n=int(input("enter the first number"))
m=int(input("enter the second number"))
print([i for i in range(n,m+1) if i<0])

Output:

Here are some basic questions on the list:

QUESTIONS
Write a python program to swap elements in the string list
Write a python program to find the length of the list
Write a python program to find a maximum of two numbers in Python
Write a python program to find a minimum of two numbers in Python
Write a python program to check if an element exists in the list
Write a python program to clear a list in Python
Write a python program to reverse a list
Write a python program to clone or Copying a list
Write a python program to count occurrences of an element in a list
Write a Python Program to find the sum and average of the list in Python

In my next blogs, you will get to know about loops and their uses.

Thank you.

More from this blog

Priya's blog

46 posts

Python Developer@Codeclause Mentee @Trailhead Salesforce Content Executive @GDSC SIT'22-23 Google Women Techmakers Ambassador @Google WTM Coreteam @ GirlScript Kolkata