Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0f25e4e

Browse files
Code
1 parent d015df0 commit 0f25e4e

File tree

89 files changed

+1244
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1244
-0
lines changed

‎ASCII_Value.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python Program to Find ASCII Value of Character.
2+
# (Use of ORD() Function)
3+
Sag = "S"
4+
print("The ASCII Value of", Sag, "is", ord(Sag))
5+
6+
sag = "s"
7+
print("The ASCII Value of", sag, "is", ord(sag))
8+
9+
Moh = "M"
10+
print("The ASCII Value of", Moh, "is", ord(Moh))
11+
12+
moh = "m"
13+
print("The ASCII Value of", moh, "is", ord(moh))
14+
15+
Gos = "$"
16+
print("The ASCII Value of", Gos, "is", ord(Gos))
17+
18+
gos = "#"
19+
print("The ASCII Value of", gos, "is", ord(gos))

‎Access_Index_List.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Python Program to Access Index of a List Using For Loop.
2+
3+
# Solution 1 : Using Enumerate Method
4+
list = [7,17,27,37,47]
5+
for index, value in enumerate(list, start=1):
6+
print(index,'-',value)
7+
8+
# Solution 2 : Not Using Enumerate Method
9+
list = [7,17,27,37,47]
10+
for index in range(len(list)):
11+
value = list[index]
12+
print(index,value)
13+

‎Add_Two_Matrices.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Python Program to Add Two Matrices.
2+
3+
A = [[1,3,5],
4+
[7,9,11],
5+
[13,15,17]]
6+
7+
B = [[2,4,6],
8+
[8,10,12],
9+
[14,16,18]]
10+
11+
Result = [[0,0,0],
12+
[0,0,0],
13+
[0,0,0]]
14+
15+
for i in range(len(A)):
16+
for j in range(len(A[0])):
17+
Result[i][j] = A[i][j] + B[i][j]
18+
19+
for r in Result:
20+
print(r)
21+

‎Add_Two_Numbers.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Write a Program Add Two Numbers in Python.
2+
# 1st Method (With Pre-defined Variables)
3+
# num1 = 45
4+
# num2 = 27
5+
# sum = num1 + num2
6+
# print("Sum is: ", sum)
7+
8+
# 2nd Method (With User Inputs)
9+
num1 = float(input("Enter the First Number: "))
10+
num2 = float(input("Enter the Second Number: "))
11+
sum = num1 + num2
12+
print("Sum is: ", sum)

‎Alphabetic_Order.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Python Program to Sort Words in Alphabetic Order.
2+
3+
# a = "Harry Potter and the Goblet of Fire"
4+
a = input("Enter Something Here: ")
5+
b = a.split()
6+
7+
print(b)
8+
9+
for i in range (len(b)):
10+
b[i] = b[i].lower()
11+
12+
print(b)
13+
b.sort()
14+
print(b)
15+
16+
# for Alphabetic Order
17+
for i in b:
18+
print(i)

‎Append_To_File.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Python Program to Append to a File.
2+
f = open("Append_To_File.txt", "a")
3+
f.write("\nThis is My Demo File")
4+
s = "\nHope You Like It"
5+
6+
for i in range(0, 5):
7+
f.write(s)
8+
f.close()

‎Append_To_File.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Hello Guys, My Name is Sagar Goswami.
2+
3+
This is My Demo File
4+
Hope You Like It
5+
Hope You Like It
6+
Hope You Like It
7+
Hope You Like It
8+
Hope You Like It

‎Area_Of_Triangle.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Python Program to Calculate the Area of a Triangle.
2+
# Solution : (0.5 X Base X Height)
3+
height = float(input("Enter the Height of the Triangle: "))
4+
base = float(input("Enter the Base of the Triangle: "))
5+
6+
area = (0.5) * height * base
7+
8+
print("The Area of Triangle is: ", area)

‎Armstrong_Number.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Python Program to Check Armstrong Number.
2+
num = int(input("Enter a Number: "))
3+
order = len(str(num))
4+
5+
sum = 0
6+
temp = num
7+
8+
while temp > 0:
9+
digit = temp % 10
10+
# sum += digit ** 3
11+
cube = digit ** order
12+
sum = sum + cube
13+
temp //= 10
14+
15+
if sum == num:
16+
print("It is an Armstrong Number")
17+
else:
18+
print("It is not an Armstrong Number")

‎Armstrong_Number_Interval.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Python Program to find Armstrong Number in an Interval.
2+
lower = int(input("Enter the Lower Limit Here: "))
3+
upper = int(input("Enter the Upper Limit Here: "))
4+
5+
for num in range(lower, upper + 1):
6+
order = len(str(num))
7+
sum = 0
8+
temp = num
9+
while temp > 0:
10+
digit = temp % 10
11+
sum += digit ** order
12+
temp //= 10
13+
if num == sum:
14+
print(num)
15+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /