diff --git a/notes/homework-solutions/1.py b/notes/homework-solutions/1.py new file mode 100644 index 0000000..fa3674d --- /dev/null +++ b/notes/homework-solutions/1.py @@ -0,0 +1,2 @@ + +print("Namaste ,nanna hesaru [Your Name]!") \ No newline at end of file diff --git a/notes/homework-solutions/2.py b/notes/homework-solutions/2.py new file mode 100644 index 0000000..1dd7d32 --- /dev/null +++ b/notes/homework-solutions/2.py @@ -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) \ No newline at end of file diff --git a/notes/homework-solutions/3.py b/notes/homework-solutions/3.py new file mode 100644 index 0000000..523e875 --- /dev/null +++ b/notes/homework-solutions/3.py @@ -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:\\") + diff --git a/notes/homework-solutions/4.py b/notes/homework-solutions/4.py new file mode 100644 index 0000000..c703755 --- /dev/null +++ b/notes/homework-solutions/4.py @@ -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)