Skip to content
Open

done #44

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Chapter 2 - PS/02_problem2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

b = 5

print("Remainder when a is divided by b is", a % b)
print("Remainder when a is divided by b is", a % b)
name="fayyaz"
age= 20
print("My name is", name, "and I am", age, "years old.")
4 changes: 3 additions & 1 deletion Chapter 2 - PS/03_problem3.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
a = input("Enter the value of a: ")
print(type(a))
print(type(a))
b=input("add number 2: ")
print(type(b))
8 changes: 6 additions & 2 deletions Chapter 2 - PS/04_problem4.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
a = int(input("Enter number 1: "))
b = int(input("Enter number 2: "))

print("a is greater than b is", a>b)
c= a+b
print("The sum of a and b is", c)
if a>b:
print("a is greater than b")
if a<b:
print("b is greater than a")
3 changes: 2 additions & 1 deletion Chapter 2 - PS/05_problem5.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
a = int(input("Enter number 1: "))
b = int(input("Enter number 2: "))

c=a+b
print("avarage of these two number is", (c)/2)

print("The average of these two number is", (a+b)/2)
3 changes: 2 additions & 1 deletion Chapter 2 - PS/06_problem6.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
a = int(input("Enter your number: "))


b=int(input("Enter your number: "))
print("b^a is", b**a)
print("The square of the number is", a**2)
print("The square of the number is", a*a)
# print("The square of the number is", a^2) # Incorrect for finding square of a number in Python
2 changes: 1 addition & 1 deletion Chapter 3 - PS/03_problem3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "Harry is a good boy and "

print(name.find(" "))
print(name.find(" boy"))
7 changes: 6 additions & 1 deletion Chapter 3/01_intro_to_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
nameshort = name[0:3] # start from index 0 all the way till 3 (excluding 3)
print(nameshort)
character1 = name[1]
print(character1)
print(character1)
name1="fayyaz"
nameshort1=name1[1:5]
print(nameshort1)
character2=name1[3]
print(character2)
3 changes: 2 additions & 1 deletion Chapter 4 - PS/03_problem3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
a = (34, 234, "Harry")

a[2] = "Larry"
a = a + ("Larry",) # Tuples are immutable, so we create a new tuple
print(a)
3 changes: 2 additions & 1 deletion Chapter 5 - PS/09_problem9.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
s = {8, 7, 12, "Harry", [1,2]}

s[4][0] = 9
s[4][0] = 9
print(s)
2 changes: 1 addition & 1 deletion Chapter 5/01_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}


# print(marks, type(marks))
print(marks, type(marks))
print(marks["Harry"])
10 changes: 5 additions & 5 deletions Chapter 5/02_dict_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
0: "Harry"
}

# print(marks.items())
# print(marks.keys())
# print(marks.values())
# marks.update({"Harry": 99, "Renuka": 100})
# print(marks)
print(marks.items())
print(marks.keys())
print(marks.values())
marks.update({"Harry": 99, "Renuka": 100})
print(marks)

print(marks.get("Harry2")) # Prints None
print(marks["Harry2"]) # Returns an error
2 changes: 1 addition & 1 deletion Chapter 7 - PS/02_problem2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
l = ["Harry", "Soham", "Sachin", "Rahul"]

for name in l:
if(name.startswith("S")):
if(name.startswith("R")):
print(f"Hello {name}")
12 changes: 6 additions & 6 deletions Chapter 7/01_loops.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
print(1)
print(2)
print(3)
print(4)
print(5)
# print(1)
# print(2)
# print(3)
# print(4)
# print(5)

# The same task can be done like this:
for i in range(1, 6):
for i in range(1, 10):
print(i)
2 changes: 2 additions & 0 deletions Chapter 8 - PS/01_problem1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ def greatest(a, b, c):
if(a>b and a>c):
return a
elif(b>a and b>c):
print("The greatest number is: b")
return b
elif(c>b and c>a):
print("The greatest number is: c")
return c

a = 1
Expand Down