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
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
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
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
Prime Numbers - Up To 10 000
PDF
100% (1)
Prime Numbers - Up To 10 000
15 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
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
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 Week 4 All GrPA's Solutions
PDF
100% (1)
Python Week 4 All GrPA's Solutions
8 pages
Python Unit 3
PDF
No ratings yet
Python Unit 3
4 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-1
PDF
No ratings yet
python_lab-1
8 pages
Cheat Sheet
PDF
No ratings yet
Cheat Sheet
2 pages
Ch7 Lists
PDF
No ratings yet
Ch7 Lists
3 pages
AI & ML Practical 1
PDF
No ratings yet
AI & ML Practical 1
10 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
Logarithm Equations
PDF
No ratings yet
Logarithm Equations
2 pages
Greatest Common Factor
PDF
No ratings yet
Greatest Common Factor
7 pages
YEAR 10 MATHS SCHEME
PDF
No ratings yet
YEAR 10 MATHS SCHEME
1 page
CryptographyNetSecurity 2008
PDF
100% (3)
CryptographyNetSecurity 2008
748 pages
College Algebra For Engineering and Allied Sciences
PDF
No ratings yet
College Algebra For Engineering and Allied Sciences
10 pages
Y10 Assessmentsets
PDF
No ratings yet
Y10 Assessmentsets
8 pages
Ma8551 Syllabus PDF
PDF
No ratings yet
Ma8551 Syllabus PDF
1 page
Ex Set 1
PDF
No ratings yet
Ex Set 1
2 pages
Grade 10 Sudoku
PDF
No ratings yet
Grade 10 Sudoku
2 pages
Formal Math-Problem-Paper2 - 2024
PDF
No ratings yet
Formal Math-Problem-Paper2 - 2024
8 pages
Recommended Mathematics Literature
PDF
No ratings yet
Recommended Mathematics Literature
5 pages
Math Syllabus (UG) CBCS (UGC) RUSA - 12 PDF
PDF
No ratings yet
Math Syllabus (UG) CBCS (UGC) RUSA - 12 PDF
133 pages
I. Numbers and Arithmatic Operations: Numbers (Bilangan) Natural Numbers (Bilangan Asli)
PDF
No ratings yet
I. Numbers and Arithmatic Operations: Numbers (Bilangan) Natural Numbers (Bilangan Asli)
13 pages
8 - Class INTSO Work Sheet - 2 - Square Roorts and Cube Roots
PDF
100% (1)
8 - Class INTSO Work Sheet - 2 - Square Roorts and Cube Roots
2 pages
PERIODIC TEST-II CLASS-VIII MATHS - New
PDF
No ratings yet
PERIODIC TEST-II CLASS-VIII MATHS - New
3 pages
Real Numbers-2_250405_124125
PDF
No ratings yet
Real Numbers-2_250405_124125
12 pages
Integers M1
PDF
No ratings yet
Integers M1
35 pages
pdf_1738340387944_250131_215004
PDF
No ratings yet
pdf_1738340387944_250131_215004
3 pages
Number Theory B Solutions
PDF
No ratings yet
Number Theory B Solutions
3 pages
Lagrangeda
PDF
No ratings yet
Lagrangeda
5 pages
(Sipnayan 2021) School Invitation
PDF
No ratings yet
(Sipnayan 2021) School Invitation
16 pages
Chap01 - 001-016 PDF
PDF
No ratings yet
Chap01 - 001-016 PDF
16 pages
Binary Subtractor and Multiplier
PDF
No ratings yet
Binary Subtractor and Multiplier
27 pages
A Gentle Introduction To Abstract Algebra
PDF
No ratings yet
A Gentle Introduction To Abstract Algebra
253 pages
TD 1 Real Numbers
PDF
No ratings yet
TD 1 Real Numbers
3 pages
On The Partial Finite Alternating Sums of Reciprocals of Balancing and Lucas-Balancing Numbers
PDF
No ratings yet
On The Partial Finite Alternating Sums of Reciprocals of Balancing and Lucas-Balancing Numbers
16 pages
Grade 7/8 Math Circles Continued Fractions A Fraction of Our History
PDF
No ratings yet
Grade 7/8 Math Circles Continued Fractions A Fraction of Our History
23 pages
Instant download Cryptanalysis of RSA and Its Variants 1st Edition M. Jason Hinek pdf all chapter
PDF
100% (1)
Instant download Cryptanalysis of RSA and Its Variants 1st Edition M. Jason Hinek pdf all chapter
47 pages
CBSE Class 8 Mathematics Ptactice Worksheet
PDF
No ratings yet
CBSE Class 8 Mathematics Ptactice Worksheet
2 pages