-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,41 @@ | ||
def get_variable_types(): | ||
"""Gets the variable types from the user.""" | ||
variable_types = [] | ||
while True: | ||
variable_type = input("Enter the variable type (int, float, str, bool): ") | ||
if variable_type in ["int", "float", "str", "bool"]: | ||
variable_types.append(variable_type) | ||
else: | ||
print("Invalid variable type.") | ||
continue | ||
if input("Do you want to add another variable type? (y/n): ") == "n": | ||
break | ||
return variable_types | ||
|
||
def get_variable_values(variable_types): | ||
"""Gets the variable values from the user.""" | ||
variable_values = [] | ||
for variable_type in variable_types: | ||
variable_value = input(f"Enter the value for the {variable_type} variable: ") | ||
variable_values.append(variable_value) | ||
return variable_values | ||
|
||
def populate_flowchart(variable_types, variable_values): | ||
"""Populates the flowchart with the variable types and values.""" | ||
flowchart = [] | ||
for i in range(len(variable_types)): | ||
variable_type = variable_types[i] | ||
variable_value = variable_values[i] | ||
flowchart.append(f"{variable_type}: {variable_value}") | ||
return flowchart | ||
|
||
def main(): | ||
"""The main function.""" | ||
variable_types = get_variable_types() | ||
variable_values = get_variable_values(variable_types) | ||
flowchart = populate_flowchart(variable_types, variable_values) | ||
print(flowchart) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|