Age calculator3/24/2023 ![]() def solver(num1, num2, num3, num4, num5, num6): Once the solve button is clicked, another function is called. The simul_2_eqn() function uses st.number_input for our users to input the numbers of the simultaneous equation. Solver(num1, num2, num3, num4, num5, num6) Num6 = right.number_input('Enter the second equal number', value=-2) Num5 = left.number_input('Enter the fourth number', value=1) Num4 = right.number_input('Enter the third number', value=1) Num3 = left.number_input('Enter the first equal number', value=3) Num2 = right.number_input('Enter the second number', value=6) Num1 = left.number_input('Enter the first number', value=1) When a choice is made from the radio button, a callback function is called. The simultaneous() function that gets executed when called gives our users the option to solve 2 or 3 unknowns variables. The simultaneous equation is fairly easy to code. Visit the documentation to understand how it works. This nicely constructed bar chart was made possible using the altair module. If they select the bar chart, a bar chart is displayed. If they choose the mean, it gets calculated. In this statistics calculator, we also gave our users several options to choose from. We then save it in the list_merged variable. The result is now a single set of numbers. We then flatten it using list comprehension. Then, in each iteration, we use repeat() to repeat each number(i) according to the frequency(i). The number and frequency were combined using the zip() function. This simple function does the job perfectly using the repeat() function from the itertools module. Remember, the frequency indicates how many times the numbers appeared. So, I created the flatten() function that does the heavy lifting for me. One of the things that make one a good programmer is to learn to find a workaround when you happen to hit a dead end. There is no function to help us compute the mean, mode and, median of data that comes with a frequency. We then prompt the user to verify that the length of the two sets of numbers is equal. Streamlit does not have a method that accepts a list of numbers.Īs a workaround, we created a lambda function that uses a regular expression to filter out the spaces or letters and accepts only numbers. That is, a set of numbers with a frequency. I made this so that our users will compute the mean, median, and mode of a grouped data. If our users select statistics from the main() function, the above function will be executed. St.altair_chart(bar, use_container_width=True) Op = st.radio('Select an operation', )ĭf = pd.DataFrame(') St.error('The numbers should be of equal length') Num = st.text_input('Please enter numbers')įreq = st.text_input('Please enter frequency') import streamlit as stįrom statistics import mean, median, mode ![]() You do well to give me your undivided attention so you can grasp what I did. This section demands a thorough explanation. If it isn’t clear, watch the video to see how I demonstrated it in a Python shell. This ensures it doesn’t add 1 to your age if you haven’t passed the exact month and day you were born. If the current date is less than your date of birth, it becomes dob.year – 0 or dob.year – 1 if it is more. We then compare your month and day of birth with the current date. We use the date function from the datetime module to transform the input details into a DateTime object. Month = st.number_input('Month of Birth', value=3)ĭay = st.number_input('Date of Birth', value=30)Īge = today.year - dob.year - ((today.month, today.day) < Year = st.number_input('Year of Birth', value=1994) This feature will tell you how old you are once you fill in the required information, that is, your date of birth.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |