Skip to content

Commit a5c3082

Browse files
Introductory Coding Questions Uploaded
1 parent 3d454ce commit a5c3082

File tree

10 files changed

+85
-0
lines changed

10 files changed

+85
-0
lines changed

0_Introduction/Question1.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Q!] Python Program to Print Hello world!
2+
3+
print("Hello World")

0_Introduction/Question10.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Q10] Python Program to Print Output Without a Newline
2+
3+
user_input1 = input("Enter a string : ")
4+
5+
user_input2 = input("Enter the second string : ")
6+
7+
print(user_input1)
8+
print()
9+
print(user_input2)

0_Introduction/Question2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Q2] Python Program to Add Two Numbers
2+
3+
num1 = int(input("Enter number 1 : "))
4+
num2 = int(input("Enter number 2 : "))
5+
6+
add = num1 + num2
7+
print("Addition of {0} and {1} is {2}".format(num1,num2,add))

0_Introduction/Question3.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Q3] Python Program to Find the Square Root
2+
3+
def sqroot(num):
4+
sol = pow(num,0.5)
5+
return round(sol,3)
6+
7+
num = int(input("Enter the number : "))
8+
9+
res = sqroot(num)
10+
print("The Square root of {0} is {1}".format(num,res))

0_Introduction/Question4.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Q4] Python Program to Calculate the Area of a Triangle
2+
3+
def areaOfTriangle(b,h):
4+
sol = (b*h)/2
5+
return round(sol,3)
6+
7+
8+
base = float(input("Enter base of the triangle : "))
9+
height = float(input("Enter height of the triangle : "))
10+
11+
res = areaOfTriangle(base,height)
12+
print("Area of the triangle is {}".format(res))

0_Introduction/Question5.py

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

0_Introduction/Question6.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Q6] Python Program to Swap Two Variables
2+
3+
num1 = int(input("Enter number 1 : "))
4+
num2 = int(input("Enter number 2 : "))
5+
6+
print("Before Swapping:-")
7+
print("Number 1 : {}".format(num1))
8+
print("Number 1 : {}".format(num2))
9+
temp = num1
10+
num1 = num2
11+
num2 = temp
12+
13+
print("After Swapping:-")
14+
15+
16+
print("Number 1 : {}".format(num1))
17+
print("Number 1 : {}".format(num2))

0_Introduction/Question7.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Q7] Python Program to Generate a Random Number
2+
3+
import random
4+
5+
6+
rand_num = random.randint(0,100)
7+
print(rand_num)

0_Introduction/Question8.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Q8] Python Program to Convert Kilometers to Miles
2+
3+
4+
km = float(input("Enter Kilometers : "))
5+
m = 1.609344*km
6+
7+
print("In meters {}".format(round(m,3)))

0_Introduction/Question9.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#Q9] Python Program to Convert Celsius To Fahrenheit
2+
3+
4+
def Fahrenheit(c):
5+
f = ((9*c)/5)+32
6+
return f
7+
8+
9+
num = float(input("Enter Celsius : "))
10+
11+
res = Fahrenheit(num)
12+
print("Fahrenheit : {}".format(res))

0 commit comments

Comments
 (0)