Lists in Python

Python3 Lists in Python

This lecture you will learn python Lists in Python!


Lists in Python

names = ['perry','rita','john','kris','alice',]
print(names)
print(names[0]) // as we calling index item from list
print(names[-1])  // for negative index item
print(names[2:]) // index print from 2 item 
print(names[2:4])  // index print range of 2 to 4
print(names[:])  // prints complete list

names = ['perry','rita','john','kris','alice',]
print(names[2:]) 
print(names)

Complete python course

also we can correct the list items on fly 

names = ['perry','rita','john','kris','alice',]
names[0] = 'per'
print(names)

output:
['per', 'rita', 'john', 'kris', 'alice']

Exercise task for beginners:

Write a program to find the largest number in a list of given 
numbers = “3, 5, 11, 2, 4, 10”

numbers = [3, 5, 11, 2, 4, 10]
max = numbers[0]
for number in numbers:
    if number > max:
        max = number
print(max)

output:
11

Python data science interview questions and answers python is a high-level programming language using Data Science programs these days

Data Science

Web development course Data Science courses: Web Development
Online courseOnline Courses: Include Certification
Harisystems is optimized for learning, testing and training. courses are designed to be simplified to improve reading and basic understanding for beginners to expert level. Tutorials and examples are constantly reviewed to avoid errors, however we cannot warrant full correctness of all content. if any found need to correct write us at info@harisystems.com. we Harisystems is not responsible for any with this tutorials, While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2007-2023 by Harisystems. All Rights Reserved.
Copyright © Harisystems 2023