Skip to content

Commit 250dcfc

Browse files
authored
Add files via upload
1 parent 5098d97 commit 250dcfc

16 files changed

+147
-0
lines changed

ap_series.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
a=int(input('enter initial number'))
2+
d=int(input('enter common difrence'))
3+
n=int(input('enter the toatl terms'))
4+
5+
for t in range (a,a+d*n,d):
6+
print(t)

break.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
for i in range (0,10):
2+
if i>5:
3+
break;
4+
else:
5+
6+
print(i)

continue.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
for i in range (0,10):
2+
# if i % 5==0:
3+
continue
4+
print(i)

dispaly_multi_table.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
n=int(input('enter the number '))
2+
for count in range (1,21):
3+
print(n,'x',count,'=',n*count)

else.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
for i in range (0,10):
2+
print(i)
3+
else:
4+
print('it print complte properly')

factor.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
n=int(input('enter a number :-'))
2+
for i in range (1,n+1):
3+
if n%i==0:
4+
print(i)

factorial.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
n=int(input('Enter a number '))
2+
factorial=1
3+
for count in range (1,n+1):
4+
factorial=factorial*count
5+
6+
print('factorial of',n,'is',factorial)

febonicci_series.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
n=int(input('enter how many terms :- '))
2+
a=0
3+
b=1
4+
5+
for i in range (n+1):
6+
print(a)
7+
c=a+b
8+
a=b
9+
b=c

match.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
day=int(input('enter day number :- '))
2+
if day==1:
3+
print('sunday')
4+
elif day==2:
5+
print('monday')
6+
elif day == 3:
7+
print('Tuesday')
8+
elif day == 4:
9+
print('Wednesday')
10+
elif day == 5:
11+
print('Thursday')
12+
elif day == 6:
13+
print('Friday')
14+
elif day == 7:
15+
print('Saturday')
16+
else:
17+
print('Invalid day number. Please enter a number between 1 and 7.')

nested.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
for i in range (0,5):
2+
for j in range (0,5):
3+
if i<=j:
4+
print('*', end='')
5+
print('')

new_nested.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
s1='abc'
2+
s2='xyz'
3+
for i in s1:
4+
for j in s2 :
5+
print(i,j,end='')
6+
print('')

pass.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for i in range (0,10):
2+
pass
3+
print('prhram ended')

pattern_for_loop.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# for i in range(0,5):
2+
# for j in range (0,5):
3+
# print('*', end='')
4+
# print('')
5+
6+
7+
for i in range(1,6):
8+
print('*'*i)

prime_number.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
n=int(input('enter a number :- '))
2+
3+
count=0
4+
5+
for i in range (1,n+1):
6+
if n%i==0:
7+
count+=1
8+
if count==2:
9+
print('number is prime')
10+
else :
11+
print('number is not prime')

prime_number1-100.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
for n in range(1, 101):
2+
count = 0
3+
for ii in range(1, n + 1):
4+
if n % ii == 0:
5+
count += 1
6+
if count == 2: # A prime number has exactly two divisors: 1 and itself
7+
print(n)

string_in_python.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
# Example of string methods
3+
4+
# Initial string
5+
text = " Hello World Python "
6+
7+
# Convert to lowercase
8+
print(text.lower()) # Output: " hello world python "
9+
10+
# Convert to uppercase
11+
print(text.upper()) # Output: " HELLO WORLD PYTHON "
12+
13+
# Capitalize each word
14+
print(text.title()) # Output: " Hello World Python "
15+
16+
# Strip leading and trailing spaces
17+
print(text.strip()) # Output: "Hello World Python"
18+
19+
# Replace 'Python' with 'Programming'
20+
print(text.replace("Python", "Programming")) # Output: " Hello World Programming "
21+
22+
# Split the string into a list of words
23+
print(text.split()) # Output: ['Hello', 'World', 'Python']
24+
25+
# Join a list of words into a single string with spaces
26+
words = ['Hello', 'World', 'Python']
27+
print(" ".join(words)) # Output: "Hello World Python"
28+
29+
# Find the position of 'World'
30+
print(text.find("World")) # Output: 11
31+
32+
# Check if the string starts with ' Hello'
33+
print(text.startswith(" Hello")) # Output: True
34+
35+
# Check if the string ends with 'Python'
36+
print(text.endswith("Python ")) # Output: True
37+
38+
# Check if the string contains only digits
39+
print("12345".isdigit()) # Output: True
40+
41+
# Check if the string contains only alphabetic characters
42+
print("Hello".isalpha()) # Output: True
43+
44+
### Key Points
45+
46+
# - **Strings are immutable:** Methods that modify a string return a new string rather than changing the original string.
47+
# - **Method chaining:** You can chain methods together for more complex operations. For example, `text.strip().upper().replace("WORLD", "EVERYONE")`.
48+

0 commit comments

Comments
 (0)