Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
3 views
2 pages
Python
Uploaded by
Shimrah akram Khan
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save python For Later
Download
Save
Save python For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
3 views
2 pages
Python
Uploaded by
Shimrah akram Khan
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save python For Later
Carousel Previous
Carousel Next
Download
Save
Save python For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 2
Search
Fullscreen
c) String slicing.
ARMSTRONG FIBONACII def string_slicing(text):
print("Original string:", text)
def is_armstrong_number(num): def fibonacci(n):
fib_series = [] print("First three characters:", text[:3])
num_str = str(num) if n <= 0: print("Characters from index 3 to 7:", text[3:8])
num_digits = len(num_str) return fib_series print("Last five characters:", text[-5:])
sum_of_cubes = 0 elif n == 1: print("Every second character:", text[::2])
fib_series.append(0) print("Reversed string:", text[::-1])
for digit in num_str: else:
def main():
sum_of_cubes += int(digit) ** num_digits fib_series = [0, 1] text = "Python Programming"
for i in range(2, n):
return sum_of_cubes == num string_slicing(text)
fib_series.append(fib_series[-1] + fib_series[-2])
def main(): return fib_series if __name__ == "__main__":
main()
num = int(input("Enter a number: ")) def main():
n = int(input("Enter the value of n to display the first n Fibonacci numbers: "))
if is_armstrong_number(num): if n <= 0:
CHECK STRING OPERATIONS
print(num, "is an Armstrong number.") print("Please enter a positive integer.")
a) len(), split(), join(), upper(), lower(), swapcase(), title(),
else:
else:
fib_series = fibonacci(n)
print(num, "is not an Armstrong number.") print("First", n, "Fibonacci numbers:") def string_operations(text):
print("Original string:", text)
if __name__ == "__main__": print(fib_series)
print("Length of the string:", len(text))
if __name__ == "__main__":
main() main()
print("Splitting the string:", text.split())
print("Joining the string with '_':", '_'.join(text.split()))
print("Uppercase:", text.upper())
FACTORIAL OF A NUMBER
print("Lowercase:", text.lower()) print("Swapping case:", text.swapcase())
def factorial_recursive(n): print("Title case:", text.title())
if n == 0: def main():
return 1 text = input("Enter a string: ")
string_operations(text)
else: if __name__ == "__main__":
return n * factorial_recursive(n - 1) main()
def main(): b) Find(), index(), count(), replace(), sorted(), strip()
def string_operations(text):
num = int(input("Enter a number: ")) print("Original string:", text)
if num < 0: print("Finding 'world':", text.find('world'))
print("Factorial is not defined for negative numbers.") print("Index of 'world':", text.index('world'))
print("Count of 'o':", text.count('o'))
else:
print("Replacing 'world' with 'Python':", text.replace('world', 'Python'))
result = factorial_recursive(num) print("Sorted characters:", sorted(text))
print("Factorial of", num, "is:", result) print("Stripped string:", text.strip())
def main():
text = " hello world! "
if __name__ == "__main__": main() string_operations(text)
main() if __name__ == "__main__":
main()
Check List and Tuple Operations. Check Dictionary and Set Operations Set Operations
a. len(), append(), extend(), insert(), remove(). i. Add Element ix.union()
my_dict = {'a': 1, 'b': 2} set1 = {1, 2, 3}
my_list = [1, 2, 3, 4, 5]
my_dict['c'] = 3 set2 = {3, 4, 5}
print(len(my_list))
print(my_dict) union_set = set1.union(set2)
my_list = [1, 2, 3]
ii.Modify Element print(union_set)
my_list.append(4) my_dict = {'a': 1, 'b': 2} x. intersection()
print(my_list) my_dict['a'] = 10 set1 = {1, 2, 3}
Print(my_dict) set2 = {3, 4, 5}
my_list = [1, 2, 3] iii. Delete Element intersection_set = set1.intersection(set2)
my_list.extend([4, 5]) my_dict = {'a': 1, 'b': 2, 'c': 3} print(intersection_set)
print(my_list) del my_dict['b'] xi. difference()
print(my_dict) set1 = {1, 2, 3}
my_list = [1, 2, 4]
iv. clear() set2 = {3, 4, 5}
my_list.insert(2, 3)
print(my_list)
my_dict = {'a': 1, 'b': 2, 'c': 3} difference_set = set1.difference(set2)
my_dict.clear() print(difference_set)
my_list = [1, 2, 3, 4, 3] print(my_dict) xii. symmetric_difference()
my_list.remove(3) v. copy() set1 = {1, 2, 3}
print(my_list) my_dict = {'a': 1, 'b': 2} new_dict = set2 = {3, 4, 5}
my_dict.copy() symmetric_difference_set =set1.symmetric_difference(set2)
b. reverse(), clear(), sort(), sorted(), count() print(new_dict) print(symmetric_difference_set)
my_list = [1, 2, 3, 4]
vi. values()
my_list.reverse() b) Modify Index of the Data and Sort the Index
my_dict = {'a': 1, 'b': 2, 'c': 3}
print(my_list)
values = my_dict.values() Modify
print(values) df.set_index('Name', inplace=True)
my_list = [1, 2, 3, 4]
my_list.clear() vii. keys() print("\nDataFrame with modified index:")
print(my_list) my_dict = {'a': 1, 'b': 2, 'c': 3} print(df)
keys = my_dict.keys()
my_list = [4, 2, 1, 3] print(keys) Sort
my_list.sort() viii.items() df.sort_index(inplace=True)
print(my_list) print("\nDataFrame after sorting index:")
my_dict = {'a': 1, 'b': 2, 'c': 3}
my_list = [4, 2, 1, 3] print(df)
items = my_dict.items()
new_list = sorted(my_list)
print(new_list)
print(items)
print(my_list)
my_list = [1, 2, 3, 2, 2, 4]
print(my_list.count(2))
You might also like
Python Hands On
PDF
100% (1)
Python Hands On
11 pages
Math
PDF
100% (1)
Math
4 pages
Python 2
PDF
No ratings yet
Python 2
2 pages
Python Programs
PDF
No ratings yet
Python Programs
26 pages
Record file
PDF
No ratings yet
Record file
35 pages
Python Lab - Programs
PDF
No ratings yet
Python Lab - Programs
27 pages
Ai Lab Internal - 1
PDF
No ratings yet
Ai Lab Internal - 1
3 pages
DOC-20250129-WA0006. (2)
PDF
No ratings yet
DOC-20250129-WA0006. (2)
13 pages
DS Lab Programs (1)
PDF
No ratings yet
DS Lab Programs (1)
47 pages
python_record_code
PDF
No ratings yet
python_record_code
33 pages
Pyhton Data Structure CheatSheet
PDF
No ratings yet
Pyhton Data Structure CheatSheet
5 pages
DSD RECORD 2
PDF
No ratings yet
DSD RECORD 2
51 pages
Pytxt
PDF
No ratings yet
Pytxt
4 pages
CS HHW
PDF
No ratings yet
CS HHW
7 pages
ds
PDF
No ratings yet
ds
6 pages
Python Experiments.HARSH[1]
PDF
No ratings yet
Python Experiments.HARSH[1]
64 pages
Python Programming Lab
PDF
No ratings yet
Python Programming Lab
10 pages
Lab-manual-Advanced Python Programming 4321602
PDF
No ratings yet
Lab-manual-Advanced Python Programming 4321602
24 pages
DATA STRUCTURE FINAL LAB MANUAL
PDF
No ratings yet
DATA STRUCTURE FINAL LAB MANUAL
57 pages
Grade 12 Practical File Ex 1 to 15 2025 26
PDF
No ratings yet
Grade 12 Practical File Ex 1 to 15 2025 26
35 pages
Lab2 Python
PDF
No ratings yet
Lab2 Python
5 pages
lab2_Python
PDF
No ratings yet
lab2_Python
5 pages
python-5
PDF
No ratings yet
python-5
16 pages
Python Answers
PDF
No ratings yet
Python Answers
6 pages
ds1
PDF
No ratings yet
ds1
6 pages
PDF
PDF
No ratings yet
PDF
13 pages
Python Experiments.niharika[1]
PDF
No ratings yet
Python Experiments.niharika[1]
64 pages
Computer Program PDF
PDF
No ratings yet
Computer Program PDF
33 pages
_bca 3rd python lab (1)
PDF
No ratings yet
_bca 3rd python lab (1)
20 pages
cs practice
PDF
No ratings yet
cs practice
5 pages
Kashu
PDF
No ratings yet
Kashu
25 pages
PYTHON_LAB_MANUAL[1]
PDF
No ratings yet
PYTHON_LAB_MANUAL[1]
12 pages
Python Programs
PDF
No ratings yet
Python Programs
6 pages
python assignment
PDF
No ratings yet
python assignment
6 pages
Python Solutions
PDF
No ratings yet
Python Solutions
11 pages
Practical File
PDF
No ratings yet
Practical File
42 pages
Class02 - Copy
PDF
No ratings yet
Class02 - Copy
8 pages
PYTHON PROGRAM LIST
PDF
No ratings yet
PYTHON PROGRAM LIST
13 pages
03.python.04.stringslistsdictionaries
PDF
No ratings yet
03.python.04.stringslistsdictionaries
47 pages
Summary Python
PDF
No ratings yet
Summary Python
4 pages
python_lab_A_B
PDF
No ratings yet
python_lab_A_B
13 pages
USER DEFINED MODULE ARYAN
PDF
No ratings yet
USER DEFINED MODULE ARYAN
29 pages
DS 8-12
PDF
No ratings yet
DS 8-12
5 pages
Python GRPA W-4
PDF
No ratings yet
Python GRPA W-4
21 pages
cbc86808-82ba-48d0-b8d1-34b4e3ce7c98
PDF
No ratings yet
cbc86808-82ba-48d0-b8d1-34b4e3ce7c98
17 pages
12 Programs Reformatted
PDF
No ratings yet
12 Programs Reformatted
22 pages
Python Manual For M.SC CS
PDF
No ratings yet
Python Manual For M.SC CS
45 pages
Untitled Document
PDF
No ratings yet
Untitled Document
8 pages
Python Unit 3
PDF
No ratings yet
Python Unit 3
4 pages
Python Week 4 All GrPA's Solutions
PDF
100% (2)
Python Week 4 All GrPA's Solutions
8 pages
1a.install Python and Set Up The Development Environment.: Code: Print ("Hello World") Output
PDF
No ratings yet
1a.install Python and Set Up The Development Environment.: Code: Print ("Hello World") Output
14 pages
python lab
PDF
No ratings yet
python lab
5 pages
Week 4 All Grpa
PDF
No ratings yet
Week 4 All Grpa
6 pages
CSCI Final Cheat Sheet
PDF
No ratings yet
CSCI Final Cheat Sheet
14 pages
Class 12 Python Programs
PDF
No ratings yet
Class 12 Python Programs
6 pages
# Addition of List Elements.
PDF
No ratings yet
# Addition of List Elements.
16 pages
19BBTCS069 KrishnaKantPandey DAP Lab Record
PDF
No ratings yet
19BBTCS069 KrishnaKantPandey DAP Lab Record
100 pages
Python Lab Manual
PDF
No ratings yet
Python Lab Manual
36 pages
python_lab-1
PDF
No ratings yet
python_lab-1
8 pages
Profound Python Data Science
From Everand
Profound Python Data Science
Onder Teker
No ratings yet
The Essential R Reference
From Everand
The Essential R Reference
Mark Gardener
No ratings yet
Difference of Two Square
PDF
100% (1)
Difference of Two Square
16 pages
SSC Math Guide Chapter 1
PDF
100% (1)
SSC Math Guide Chapter 1
24 pages
Complete Download Introduction To Analytic and Probabilistic Number Theory 3rd Edition Gerald Tenenbaum PDF All Chapters
PDF
100% (2)
Complete Download Introduction To Analytic and Probabilistic Number Theory 3rd Edition Gerald Tenenbaum PDF All Chapters
62 pages
Elitmus Previous Year Paper
PDF
No ratings yet
Elitmus Previous Year Paper
18 pages
Download full (Ebook) An Invitation To Algebraic Numbers And Algebraic Functions by Franz Halter-Koch (Author) ISBN 9780429014666, 9780429014673, 9780429506550, 9781138583610, 042901466X, 0429014678, 0429506554, 1138583618 ebook all chapters
PDF
100% (3)
Download full (Ebook) An Invitation To Algebraic Numbers And Algebraic Functions by Franz Halter-Koch (Author) ISBN 9780429014666, 9780429014673, 9780429506550, 9781138583610, 042901466X, 0429014678, 0429506554, 1138583618 ebook all chapters
76 pages
GMAT Practice Questions
PDF
No ratings yet
GMAT Practice Questions
18 pages
Unit Iii Notes - Final
PDF
No ratings yet
Unit Iii Notes - Final
31 pages
Public
PDF
No ratings yet
Public
22 pages
PY
PDF
No ratings yet
PY
8 pages
Subtraction of Integers 1
PDF
No ratings yet
Subtraction of Integers 1
6 pages
Binomial Theorem 0609eba9 7d2f 4c1f 9a83 9cd0d328c8f5
PDF
No ratings yet
Binomial Theorem 0609eba9 7d2f 4c1f 9a83 9cd0d328c8f5
27 pages
Railway Algebra Complete Chapter
PDF
No ratings yet
Railway Algebra Complete Chapter
15 pages
Exhaustive Proof and Proof by Cases
PDF
No ratings yet
Exhaustive Proof and Proof by Cases
28 pages
Mathematics-4 Quarter 3 Least Common Multiple (LCM)
PDF
No ratings yet
Mathematics-4 Quarter 3 Least Common Multiple (LCM)
18 pages
4.PolynomialsTrans-11MM-2025-PracticeQuiz1-Sol
PDF
No ratings yet
4.PolynomialsTrans-11MM-2025-PracticeQuiz1-Sol
5 pages
Class-8-Maths-WS-6 Rational Numbers
PDF
No ratings yet
Class-8-Maths-WS-6 Rational Numbers
8 pages
Important Notes of 10th Class Math Exercise 2.8
PDF
No ratings yet
Important Notes of 10th Class Math Exercise 2.8
5 pages
Fibonacci Number: History Sequence Properties Relation To The Golden Ratio
PDF
No ratings yet
Fibonacci Number: History Sequence Properties Relation To The Golden Ratio
25 pages
Master - Strategies - in - Computing - VERDIC MATH
PDF
No ratings yet
Master - Strategies - in - Computing - VERDIC MATH
65 pages
Finite Field Arithmetic
PDF
No ratings yet
Finite Field Arithmetic
8 pages
2009 Metrobank Mtap Reviewer
PDF
No ratings yet
2009 Metrobank Mtap Reviewer
2 pages
Order of Operations With Integers - Worksheet
PDF
100% (1)
Order of Operations With Integers - Worksheet
2 pages
Cns Assignment 4
PDF
No ratings yet
Cns Assignment 4
6 pages
P3 Binomial Expressions Inserted 20200
PDF
No ratings yet
P3 Binomial Expressions Inserted 20200
3 pages
Quantitative Aptitude PDF
PDF
No ratings yet
Quantitative Aptitude PDF
163 pages
Problems On Congruences and Divisibility: 18.S34 (FALL 2007)
PDF
No ratings yet
Problems On Congruences and Divisibility: 18.S34 (FALL 2007)
4 pages
Olympiad Workshop - Lecture-3 - IOQM - (Sol.)
PDF
No ratings yet
Olympiad Workshop - Lecture-3 - IOQM - (Sol.)
2 pages
Mathematics: (Philippine Elementary Learning Competencies) Basic Education Curriculum
PDF
No ratings yet
Mathematics: (Philippine Elementary Learning Competencies) Basic Education Curriculum
34 pages