Using a Python dictionary value in a calculation [closed] - python

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
I have some Python code that takes user input for mass and diameter of an object. Those data parameters I later use in a calculation formula. Instead of having the user input those two values, I now have a dictionary that stores the values. How can I now have those values extracted from the dictionary and placed into the calculation formula? I'm very new to Python and trying to figure out if this done via a while loop or defining an function within a while loop, etc.
Thanks.

Related

How do I read the last item from a list that's inside of a list that's all part of a single variable [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
I'm making a blackjack game that requires me to calculate the scores at the end of multiple games such as what your cards added up to at the end of the games and find out the mean, mode and frequency. I've gotten the data laid out in a spread sheet but can't figure out how to read and add the score from the separate games since they're all being added together into one variable
My python code that prints and reads out the stats
The stats my code gets the data from

how to find the values of a sum with decimals [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
I would like to know how to find the values of a list that result in the sum of a specific value example that I have a list of payments but a payment is found that comes from different values of the list that added together result in the total value of the payment
I just want to know how to find the values of a sum in a way to be program it

When to use Lists, Sets, Dictionaries, or tuples in python? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I'm new to python, and I'm a bit confused about the use cases of data types in python
Can someone please explain in detail when to use each data type, with an example if possible
Thank you.
Lists are used when you have data you want to further modify, alter like sorting and all.
Dictionary is used when you have to sets of data where data of the first set corresponds to data of other set. And the position of the data doesn't matter only the relation of the two sets matters.
A tuple is used when position of the data is very important and you don't want to alter the position throughout.

Pandas Python iteration or mod [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to do an iteration with Pandas or any built-in function to display multiple of 10 rows for example.
So e.g. there are 50 records and I want to display the multiple of 10 records which will be record ID 0,10,20,30,40,50.
Use iloc:
df.iloc[::10, :]
This method takes a row/column slice, both based on integer position. More details from documenation:
Purely integer-location based indexing for selection by position.
.iloc[] is primarily integer position based (from 0 to length-1 of the axis), but may also be used with a boolean array.

Python and Variable Assignment [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
This is just a question and I don't have any example code. But let's say that you were to make a python program were you have a "star" variable the star variable holds an integer and that integer is the age of the star, each time the program loops it adds a value of 1 to the star variable and if the star variable is equal to 100 it will create a new star which has its variable and the same process will occur with this variable as well.
How would you create a whole new variable or something along these lines without assigning one while writing the program?
You could store the object in a list. As a new star is created, just append it.

Categories