Skip to content

Commit 42f6b34

Browse files
authored
Merge pull request #19 from zcsop1206/BMI_code_changes
added a file to calculate BMI of an individual. Functions to accept d…
2 parents 23461a6 + 83f377d commit 42f6b34

8,742 files changed

Lines changed: 335920 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.replit

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing
2+
run = "python3 main.py"
3+
4+
# The primary language of the repl. There can be others, though!
5+
language = "python3"
6+
entrypoint = "main.py"
7+
# A list of globs that specify which files and directories should
8+
# be hidden in the workspace.
9+
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]
10+
11+
# Specifies which nix channel to use when building the environment.
12+
[nix]
13+
channel = "stable-21_11"
14+
15+
# The command to start the interpreter.
16+
[interpreter]
17+
[interpreter.command]
18+
args = [
19+
"stderred",
20+
"--",
21+
"prybar-python3",
22+
"-q",
23+
"--ps1",
24+
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
25+
"-i",
26+
]
27+
env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }
28+
29+
[env]
30+
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
31+
PATH = "${VIRTUAL_ENV}/bin"
32+
PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.10/site-packages"
33+
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
34+
MPLBACKEND = "TkAgg"
35+
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"
36+
37+
# Enable unit tests. This is only supported for a few languages.
38+
[unitTest]
39+
language = "python3"
40+
41+
# Add a debugger!
42+
[debugger]
43+
support = true
44+
45+
# How to start the debugger.
46+
[debugger.interactive]
47+
transport = "localhost:0"
48+
startCommand = ["dap-python", "main.py"]
49+
50+
# How to communicate with the debugger.
51+
[debugger.interactive.integratedAdapter]
52+
dapTcpAddress = "localhost:0"
53+
54+
# How to tell the debugger to start a debugging session.
55+
[debugger.interactive.initializeMessage]
56+
command = "initialize"
57+
type = "request"
58+
59+
[debugger.interactive.initializeMessage.arguments]
60+
adapterID = "debugpy"
61+
clientID = "replit"
62+
clientName = "replit.com"
63+
columnsStartAt1 = true
64+
linesStartAt1 = true
65+
locale = "en-us"
66+
pathFormat = "path"
67+
supportsInvalidatedEvent = true
68+
supportsProgressReporting = true
69+
supportsRunInTerminalRequest = true
70+
supportsVariablePaging = true
71+
supportsVariableType = true
72+
73+
# How to tell the debugger to start the debuggee application.
74+
[debugger.interactive.launchMessage]
75+
command = "attach"
76+
type = "request"
77+
78+
[debugger.interactive.launchMessage.arguments]
79+
logging = {}
80+
81+
# Configures the packager.
82+
[packager]
83+
language = "python3"
84+
ignoredPackages = ["unit_tests"]
85+
86+
[packager.features]
87+
enabledForHosting = false
88+
# Enable searching packages from the sidebar.
89+
packageSearch = true
90+
# Enable guessing what packages are needed from the code.
91+
guessImports = true
92+
93+
# These are the files that need to be preserved when this
94+
# language template is used as the base language template
95+
# for Python repos imported from GitHub
96+
[gitHubImport]
97+
requiredFiles = [".replit", "replit.nix", ".config", "venv"]
98+
99+
[languages]
100+
101+
[languages.python3]
102+
pattern = "**/*.py"
103+
104+
[languages.python3.languageServer]
105+
start = "pylsp"

BMI.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
def input_variables():
2+
3+
print("Name:")
4+
name = input("Enter the name of the person.")
5+
6+
print("Age:")
7+
age = int(input("Enter the age of the person."))
8+
9+
print("Sex:")
10+
sex = input("Enter sex: M for male, F for female, O for non binary.")
11+
while sex!= 'M' and sex!='F' and sex!='O':
12+
print("Incorrect choice.")
13+
sex = input("Enter sex: M for male, F for female, O for non binary.")
14+
15+
print("Weight:")
16+
unit_weight = input("Press 1 for kilograms, 2 for pounds.")
17+
while unit_weight!= '1' and unit_weight!='2':
18+
print("Incorrect choice.")
19+
unit_weight = input("Press 1 for kilograms, 2 for pounds.")
20+
if unit_weight == '1':
21+
weight_in_kg = float(input("Enter the weight of the person in kilograms."))
22+
else:
23+
weight_in_kg = float(input("Enter the weight of the person in pounds."))*0.453592
24+
25+
print("Height:")
26+
unit_height = input("Press 1 for meters and centimeters, 2 for feet and inches")
27+
while unit_weight!= '1' and unit_weight!='2':
28+
print("Incorrect choice.")
29+
unit_height = input("Press 1 for meters and centimeters, 2 for feet and inches")
30+
if unit_height == '1':
31+
height_in_m = float(input("Enter the height of the person in meters.")) + float(input("Enter the remaining height of the person in centimeters"))*0.01
32+
else:
33+
height_in_m = (float(input("Enter the height of the person in feet"))*12 + float(input("Enter the remaining height of the person in inches")))*0.0254
34+
35+
return name, age, sex, weight_in_kg, height_in_m
36+
37+
def calculate_BMI(info):
38+
wt = info[3]
39+
ht = info[4]
40+
BMI = wt/(ht**2)
41+
42+
return BMI
43+
44+
def find_body_state(BMI):
45+
if BMI<18.5:
46+
body_state = 'underweight'
47+
elif BMI<24.9:
48+
body_state = 'normal'
49+
elif BMI<29.9:
50+
body_state = 'overweight'
51+
else:
52+
body_state = 'obese'
53+
54+
return body_state
55+
56+
def output():
57+
info = input_variables()
58+
BMI = calculate_BMI(info)
59+
body_state = find_body_state(BMI)
60+
61+
print("Name: {}\nAge: {}\nGender: {}\nWeight(in kg): {:.3f}\nHeight(in m): {:.2f}\nBody Mass Index: {:.2f}\nAcoording to your body mass index, you are {}.".format(info[0], info[1], info[2], info[3], info[4], BMI, body_state))
62+
63+
output()
64+

replit.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ pkgs }: {
2+
deps = [
3+
pkgs.python38Full
4+
];
5+
env = {
6+
PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
7+
# Needed for pandas / numpy
8+
pkgs.stdenv.cc.cc.lib
9+
pkgs.zlib
10+
# Needed for pygame
11+
pkgs.glib
12+
# Needed for matplotlib
13+
pkgs.xorg.libX11
14+
];
15+
PYTHONBIN = "${pkgs.python38Full}/bin/python3.8";
16+
LANG = "en_US.UTF-8";
17+
};
18+
}

0 commit comments

Comments
 (0)