Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centigrade to fahrenheit #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
18 changes: 18 additions & 0 deletions python/Arc length of a circle/arcLength.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#python code for finding the arc length of the angle.

##impotr math package to use math.pi for the value of PI
import math
#create a function to calculate the arc length.
def arclength():
# take input diameter and angle .
d= float(input("please Enter the diameter of circle: "))
Angle = float(input("please Enter the angle value: "))
# checking for the angle validation
if Angle >= 360:
print("Invalid angle entered ")
return
#calculate arc length.
Arc_length = (math.pi*d) * (Angle/360)
print("the arc Length will be : %.2f" %Arc_length)
#function call
arclength()
73 changes: 73 additions & 0 deletions python/Binary to Octal/bin_to_octal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Python3 implementation to convert a binary number
# to octal number

# function to create map between binary
# number and its equivalent octal
def createMap(bin_oct_map):
bin_oct_map["000"] = '0'
bin_oct_map["001"] = '1'
bin_oct_map["010"] = '2'
bin_oct_map["011"] = '3'
bin_oct_map["100"] = '4'
bin_oct_map["101"] = '5'
bin_oct_map["110"] = '6'
bin_oct_map["111"] = '7'

# Function to find octal equivalent of binary
def convertBinToOct(bin):
l = len(bin)

# length of string before '.'
t = -1
if '.' in bin:
t = bin.index('.')
len_left = t
else:
len_left = l

# add min 0's in the beginning to make
# left substring length divisible by 3
for i in range(1, (3 - len_left % 3) % 3 + 1):
bin = '0' + bin

# if decimal point exists
if (t != -1):

# length of string after '.'
len_right = l - len_left - 1

# add min 0's in the end to make right
# substring length divisible by 3
for i in range(1, (3 - len_right % 3) % 3 + 1):
bin = bin + '0'

# create dictionary between binary and its
# equivalent octal code
bin_oct_map = {}
createMap(bin_oct_map)
i = 0
octal = ""

while (True) :

# one by one extract from left, substring
# of size 3 and add its octal code
octal += bin_oct_map[bin[i:i + 3]]
i += 3
if (i == len(bin)):
break

# if '.' is encountered add it to result
if (bin[i] == '.'):
octal += '.'
i += 1

# required octal number
return octal

# Driver Code
bin = "1111001010010100001.010110110011011"
print("Octal number = ",
convertBinToOct(bin))


11 changes: 11 additions & 0 deletions python/Centigrade to Fahrenheit/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Temprature in celsius degree
celsius = 40

# Converting the temprature to
# fehrenheit using the above
# mentioned formula
fahrenheit = (celsius * 1.8) + 32

# printing the result
print('%.2f Celsius is equivalent to: %.2f Fahrenheit'
%(celsius, fahrenheit))