Python Forum
Question about formula implementation in general format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about formula implementation in general format
#1
Hello,


I have the following formula:

y = a1cos(θ1) +a2cos(θ1+θ2) +...+ancos(θ1+...+θn)

The goal is to implement it in Python so it works with any number of a-value/theta angles combination.

So far I have written code which stores in two separate dictionaries:

A combination of a-value number and a value
A combination of a-value number and an angle value
This is implemented via two for loops where i is the number of values the user wants the formula to work with. Here is the code:

a_values_list = {}
a_number = int(input("\nHow many values of a would you like to enter?"))


for i in range(0, a_number):
    key = input("Input a-value number")
    value = input("Input corresponding value of a")
    a_values_list[key] = value


angles_list = {}

for i in range(0,a_number):
    key = input('Input a-value number')
    value = input("\n Enter a corresponding angle displacement between 0 and pi")
    angles_list[key] = value

I need help with the following:

Figuring out how to implement the formula based on the number of a-values/angle combinations stored in the dictionaries
Getting the angle values from the dictionaries and adding them within the cos statements
Thank you for your time
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python can - general question caslor 0 1,113 Jul-14-2022, 05:21 PM
Last Post: caslor
  a general question barryjo 5 1,489 Feb-01-2022, 10:12 PM
Last Post: Gribouillis
  General Programming Question with Dictionary giddyhead 12 2,692 Jan-10-2022, 10:12 AM
Last Post: Pedroski55
Big Grin General programming question (input string)[ jamie_01 2 1,591 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Python “Formula” Package: How do I parse Excel formula with a range of cells? JaneTan 1 2,675 Jul-12-2021, 11:09 AM
Last Post: jefsummers
  General list size question to solve problem Milfredo 3 2,348 Sep-27-2020, 08:42 AM
Last Post: Milfredo
  General Listbox question. Milfredo 4 2,140 Sep-06-2020, 07:36 PM
Last Post: Milfredo
  General question about serialization/deserialization in python local 1 1,838 Jan-28-2020, 04:35 AM
Last Post: Larz60+
  Simple question about .format(* ) Motley_Cow 1 2,021 Oct-03-2019, 07:13 AM
Last Post: buran
  Definition of .format? (Newbie question) Jan_97 4 2,681 Jul-13-2019, 12:49 PM
Last Post: Jan_97

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020