Skip to content
Open
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
2 changes: 2 additions & 0 deletions notes/homework-solutions/1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

print("Namaste ,nanna hesaru [Your Name]!")
30 changes: 30 additions & 0 deletions notes/homework-solutions/2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
##1:
# Declare the variables as a and b
a=5
b=7
# Printing the results of each operations
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a//b)
print(a%b)
print(a**b)

##2:
# With using a third variable:
print("With using a third variable:")
a,b=3,6
print("Before Swapping a and b: \na= ",a,"\nb= ",b)
temp=a
a=b
b=temp
print("After swapping with a third variable(temp): \na= ",a,"\nb= ",b)

#Without using a third variable
print("Without using a third variable:")

c,d=4,5
print("Before swapping:\nx= ",c,"\nd= ",d)
c,d=d,c
print("After swapping without a third variable: \nx= ",c,"\nd= ",d)
23 changes: 23 additions & 0 deletions notes/homework-solutions/3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
##1

name=input("Enter your name: ")
age=int(input("Enter your age: "))
print(f"Hello,",name,"!","You are ",age,"years old.")

##2

sentence = input("Enter the sentence:")
print(sentence.upper())
print(sentence.lower())
print(sentence.replace(" ","_"))
print(sentence.strip())

##3

count =input("Enter a sentence:")
print(len(count.replace(" ","")))

##4

print("Hello\n\tWorld\nThis is a backslash:\\")

27 changes: 27 additions & 0 deletions notes/homework-solutions/4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
##1
a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
print(a>10 and b>10)
print(a==5 or b==5)
print(not(a>b))

##2

age=int(input("Enter your age:"))
if(age>=18):
print("You are an adult!!")
if(age<18):
print("You are a minor.")

##3

word = input("Enter a word:")
print("a" in word)
print("Python" not in word)

##4

a,b=10,12
print(a&b,a|b,a^b)
print(a<<2)
print(b>>1)