Skip to content

Commit bf2cbfd

Browse files
committed
Updated project
1 parent 64d6f4e commit bf2cbfd

5 files changed

Lines changed: 180 additions & 1 deletion

File tree

‎Students/kamala/autobgchanger.html‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
<div class="container">
10+
11+
</div>
12+
</body>
13+
<script></script>
14+
</html>

‎Students/kamala/calculater.py‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#input => operation => output
2+
3+
num1 = float(input("Enter a number: "))
4+
operation = input("Enter an operation (+, -, *, /): ")
5+
6+
num2 = float(input("Enter another number: "))
7+
if operation == "+":
8+
result = num1 + num2
9+
elif operation == "-":
10+
result = num1 - num2
11+
elif operation == "*":
12+
result = num1 * num2
13+
elif operation == "/":
14+
if num2 != 0:
15+
result = num1 / num2
16+
else:
17+
result = "Error: Division by zero is not allowed."
18+
else:
19+
result = "Error: Invalid operation."
20+
print("Result:", result)
21+
# 2/0=Error: Division by zero is not allowed.
22+
#conversion of data types in python
23+
24+
# number to string
25+
num = 10.3
26+
complex_num = 2 + 3j
27+
str_num = str(num)#"10.3"
28+
str_complex_num = str(complex_num)#"(2+3j)"
29+
30+
# string to number
31+
str_num = "10.3"
32+
num = float(str_num)#10.3
33+
str_complex_num = "2 + 3j"
34+
complex_num = complex(str_complex_num)#(2+3j)
35+
36+
# name="saugat" X
37+
# name=int(name) # this will give an error because we cannot convert a string to an integer
38+
39+
# number and string to boolean
40+
num = 0
41+
str_num = ""
42+
bool_num = bool(num) # this will give False because 0 is considered as False in python
43+
bool_str_num = bool(str_num) # this will give False because an empty string is considered
44+
none_value = None
45+
bool_none_value = bool(none_value) # this will give False because None is considered as False in python
46+
print("bool of num:", bool_num)
47+
print("bool of str_num:", bool_str_num)
48+
print("bool of none_value:", bool_none_value)
49+
#number in python
50+
#data type of number in python
51+
int_num = 10
52+
float_num = 10.5
53+
complex_num = 2 + 3j
54+
print("type of ",int_num, "is", type(int_num))
55+
print("type of ",float_num, "is", type(float_num))
56+
print("type of ",complex_num, "is", type(complex_num))
57+
58+
import random
59+
print(random.randint(1, 100)) # to generate a random number between 1 and 100

‎Students/kamala/index1.html‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ <h2>To Do List</h2>
6262

6363
<script>
6464
function addTask(){
65-
65+
// doc = Whole webpage. Find element named task. . value = Get what user typed. like if user type home then tasks="home"
6666
let task=document.getElementById("task").value;
6767

6868
if(task==""){
69+
// Popup says: enter task
6970
alert("Enter task");
7071
return;
7172
}

‎Students/kamala/py-task1.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# 2.Gym memberships are priced based on age: $25 for adults (18 and over), $15 for children. Everyone gets a $5 discount on januarry
2+
age = int(input("Enter your age: "))
3+
month = input("Enter the month 1-12: ")
4+
5+
match month:
6+
case "1":
7+
month="january"
8+
case "2":
9+
month="february"
10+
case "3":
11+
month="march"
12+
case "4":
13+
month="april"
14+
case "5":
15+
month="may"
16+
case "6":
17+
18+
month="june"
19+
case "7":
20+
month="july"
21+
case "8":
22+
month="august"
23+
case "9":
24+
month="september"
25+
case "10":
26+
month="october"
27+
case "11":
28+
month="november"
29+
case "12":
30+
month="december"
31+
case _:
32+
print("Invalid month number. Please enter a number between 1 and 12.")
33+
if month == "january":
34+
if age >= 18:
35+
price = 25 - 5
36+
print(f"Your gym membership price is: ${price}")
37+
else:
38+
price = 15 - 5
39+
print(f"Your gym membership price is: ${price}")
40+
else:
41+
if age >= 18:
42+
price = 25
43+
print(f"Your gym membership price is: ${price}")
44+
else:
45+
price = 15
46+
print(f"Your gym membership price is: ${price}")

‎Students/kamala/random.py‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#number in python
2+
#data type of number in python
3+
int_num = 10
4+
float_num = 10.5
5+
complex_num = 2 + 3j
6+
print("type of ",int_num, "is", type(int_num))
7+
print("type of ",float_num, "is", type(float_num))
8+
print("type of ",complex_num, "is", type(complex_num))
9+
10+
import random
11+
print(random.randint(1, 100)) # to generate a random number between 1 and 100
12+
13+
suman Bishwakarma
14+
20:52
15+
screen off vayo
16+
17+
SAUGAT
18+
20:59
19+
# string in python
20+
name = "saugat"
21+
print("name:", name)
22+
print("type of name:", type(name))
23+
print("character at index 0:", name[0])
24+
print("length of name:", len(name))
25+
26+
decription = """
27+
this is a multi line string
28+
we can use triple quotes to create a multi line string
29+
this is the end of the multi line string
30+
"""
31+
32+
print("description:", decription)
33+
concatination = name + " is a teacher"
34+
print("concatination:", concatination)
35+
print("index 1 of description:", decription[1])
36+
37+
38+
#is smth in description
39+
print("saugat " in decription)# false
40+
print("saugat " not in decription)# true
41+
42+
# string methods
43+
print("name in uppercase:", name.upper())
44+
print("name in lowercase:", name.lower())
45+
print(dir(name)) # to see all the methods of string
46+
#capitalize the first letter of the string
47+
print("name with capitalized first letter:", name.capitalize())# first letter of the string will be capitalized and the rest will be in lowercase
48+
print("name with capitalized first letter:", name.title()) # to capitalize the first letter of each word in the string
49+
50+
sentence = " this is a sentence with leading and trailing spaces "
51+
print("sentence with leading and trailing spaces:", sentence.strip()) # to remove leading and trailing spaces from the string
52+
53+
list_of_words = "apple, banana, orange"
54+
print("list of words:", list_of_words.split(", ")) # to split the string into a list of words based on the delimiter ", "
55+
#replace
56+
print("name with replaced characters:", name.replace("s", "R")) # to replace all occurrences of "a" with "o" in the string
57+
58+
#index
59+
print("index of a in name:", name.index("a")) # to find the index of the first occurrence of "a" in the string

0 commit comments

Comments
 (0)