Adil Khan 6 years ago

Solved - Lab Assignment No 2

# -*- coding: utf-8 -*-
"""
Created on Tue Oct 15 20:54:42 2019

@author: AdilKhan
"""

#Question No 1: String Functions

print(" String Functions")
print("---------------------------------------------")
myString = "My Name is Adil Khan"

print("Aactual String is :",myString )

#lower case
print("Lower Case: ",myString.lower());

#upper case
print("Upper Case: ",myString.upper())

#replace
print("Replacing Adil with Naveed: ", myString.replace("Adil","Naveed"))

#count
print("Adil repeats ",myString.count("Adil")," times in string")

#index
print("Index of Adil Starts at: ",myString.index("Adil"))

#len
print("Length of the string is ",len(myString))

# Questioin No 2: List and List Functions
print(" List Function")
print("---------------------------------------------")

myList = [3,5,8,3,2]

print("myList Elements are : ",myList)

#length of list
print("Length of myList is ",len(myList))

#sum
print("Sum of myList is ",sum(myList))

#max
print("Maximum number in myList is ",max(myList))

#min
print("Minimum number in myList is ",min(myList))

#append
print("Appending a new number 7 in myList")
myList.append(7)
print("myList Elements are : ",myList)

#sort
myList.sort()
print("myList after Sorting : ",myList)


#count
print("Number 3 exists ",myList.count(3)," times in myList")

#index
print("Number 5 can b found on index ",myList.index(5)," in myList")

#reverse
myList.reverse()
print("myList after Reversing : ",myList)

#remove
print("Removing number 5 from myList")
myList.remove(5)
print("myList without 5 is : ",myList)

#pop
print("Pop element at the end")
myList.pop()
print("myList after poping is : ",myList)
print("Pop element at the index 2")
myList.pop(2)
print("myList after poping is : ",myList)

#insert
print("Inserting number 9 at index 3")
myList.insert(3,9)
print("myList after insertion is : ",myList)


 

Solved - Lab Assignment No 2 _ 0.zip

Download: Solved - Lab Assignment No 2 _ 0.zip

0
1.3K
design and development of an assistive smart shoe for visually impaire...

2.2 billion people on earth are not fortunate enough to have clear vision. about 1 billion...

1675638330.png
Adil Khan
1 year ago
Smart Gloves for converting sign to speech

About 9 billion people around the globe are deaf-mute which is an effective percentage of...

1675638330.png
Adil Khan
1 year ago
University Admission Counselor System

We are making University Admission Counselling System that is the platform for all th...

1675638330.png
Adil Khan
1 year ago
To design automotive occupant package for Pakistan

Modern-day transportation for the masses is under constant research and development, one s...

1675638330.png
Adil Khan
1 year ago
An Editor to Autocomplete sentences in Urdu using Natural Language Pro...

Natural language processing (NLP) is the intersection of computer science, linguistics and...

1675638330.png
Adil Khan
1 year ago