Skip to content

Commit aaefb17

Browse files
committed
Write a program to sort (ascending order) a dictionary by value
1 parent bd179ed commit aaefb17

19 files changed

+172
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode/

43.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dictionary = {"Suka":600000,"Indra":700000,"Abhra":500000,"Shoob":800000}
2+
sorted_dictionary = dict(sorted(dictionary.items(),key = lambda item:item[1]))
3+
print("The sorted dictionary is:",sorted_dictionary)

change_occur.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
s = input("Enter a string: ")
2+
last_char = s[-1]
3+
new_string = s[:-1].replace(last_char,'*') + last_char
4+
print("New string:",new_string)

happy_birthday.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = input("Enter the name of your friend: ")
2+
for i in range(1,10):
3+
print("Happy Birthday", name, "from A")

http_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# python -m http.server --bind=localhost

image.png

1.34 KB
Loading

index.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>Bootstrap demo</title>
7+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
8+
</head>
9+
<body>
10+
<nav class="navbar navbar-expand-lg bg-body-primary bg-dark" data-bs-theme="dark">
11+
<div class="container-fluid">
12+
<a class="navbar-brand" href="#">Navbar</a>
13+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
14+
<span class="navbar-toggler-icon"></span>
15+
</button>
16+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
17+
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
18+
<li class="nav-item">
19+
<a class="nav-link active" aria-current="page" href="#">Home</a>
20+
</li>
21+
<li class="nav-item">
22+
<a class="nav-link" href="#">Link</a>
23+
</li>
24+
<li class="nav-item dropdown">
25+
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
26+
Dropdown
27+
</a>
28+
<ul class="dropdown-menu">
29+
<li><a class="dropdown-item" href="#">Action</a></li>
30+
<li><a class="dropdown-item" href="#">Another action</a></li>
31+
<li><hr class="dropdown-divider"></li>
32+
<li><a class="dropdown-item" href="#">Something else here</a></li>
33+
</ul>
34+
</li>
35+
<li class="nav-item">
36+
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
37+
</li>
38+
</ul>
39+
<form class="d-flex" role="search">
40+
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
41+
<button class="btn btn-outline-success" type="submit">Search</button>
42+
</form>
43+
</div>
44+
</div>
45+
</nav>
46+
<div class="card" style="width: 18rem;">
47+
<img src="tiger.jpg" class="card-img-top" alt="...">
48+
<div class="card-body">
49+
<h5 class="card-title">Card title</h5>
50+
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
51+
<a href="#" class="btn btn-primary">Go somewhere</a>
52+
</div>
53+
</div>
54+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
55+
</body>
56+
</html>

iteration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
numbers = (1, 2, 3, 4, 5, 6)
2+
for num in numbers:
3+
print(num)
4+
5+
print(tuple(numbers))

kirana_store.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sum = 0
2+
count = 1
3+
while True:
4+
userInput = input("Enter the item price or press q to quit: ")
5+
f = open("receipt.txt","a")
6+
if userInput != 'q':
7+
sum = sum + int(userInput)
8+
print(f"Order total so far {sum}")
9+
f.write(f"{count}.{userInput}\n")
10+
count = count + 1
11+
else:
12+
print(f"Your Total Bill is {sum}. Thanks for shopping with us")
13+
break
14+
15+
f.close()

pattern.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<stdio.h>
2+
3+
int main(){
4+
int i,j,rows;
5+
printf("Enter the number of rows: ");
6+
scanf("%d",&rows);
7+
for (i = 1; i <= rows; i++)
8+
{
9+
for (j = 1; j <= i; j++)
10+
{
11+
printf("* ");
12+
}
13+
printf("\n");
14+
}
15+
16+
return 0;
17+
}

pattern.exe

40.5 KB
Binary file not shown.

receipt.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
1.45
2+
2.56
3+
3.78
4+
4.89
5+
5.90
6+
1.45
7+
2.3
8+
3.43
9+
4.3
10+
5.4

sort.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
a = int(input("Enter first number: "))
2+
b = int(input("Enter second number: "))
3+
c = int(input("Enter third number: "))
4+
print("Numbers after sorting: ")
5+
if a<b:
6+
if b<c:
7+
print(a,b,c)
8+
elif a<c:
9+
print(a,c,b)
10+
else:
11+
print(c,a,b)
12+
else:
13+
if c<b:
14+
print(c,b,a)
15+
elif c<a:
16+
print(b,c,a)
17+
else:
18+
print(b,a,c)

string_palindrome.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
s = input("Enter a string: ")
2+
s = s.lower().replace(" ","")
3+
r = s[:-1]
4+
print(r)
5+
6+
if s == r:
7+
print(s, "is a palindrome")
8+
else:
9+
print(s, "is not a palindrome")

substring.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sen = input("Enter a sentence:")
2+
word = input("Enter a word:")
3+
words = sen.split()
4+
count = 0
5+
# print(words)
6+
for i in words:
7+
if i == word:
8+
count += 1
9+
print(count)
10+
print("The word",word,"occurs",count,"times in the sentence")

sum_of_prime.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
l = int(input("Enter the lower range: "))
2+
h = int(input("Enter the upper range: "))
3+
sum = 0
4+
for num in range(l, h+1):
5+
if num > 1:
6+
for i in range(2, num):
7+
if num % i == 0:
8+
break
9+
else:
10+
sum += num
11+
12+
print("The sum of the prime numbers between range", l, "and", h, "will be:",sum)

tiger.jpg

263 KB
Loading

vowels.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
vowels = ['a','e','i','o','u']
2+
sentence = input("Enter a sentence: ")
3+
sentence = sentence.lower()
4+
count = [0,0,0,0,0]
5+
for char in sentence:
6+
if char in vowels:
7+
count[vowels.index(char)] += 1
8+
print(count)

whatsapp.py

Whitespace-only changes.

0 commit comments

Comments
 (0)