473,287 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

dividing an int by a float in trinket to calculate decay rates.

Hi all, i could use a little help with this one, i'm supposed to be calculating decay rates using specifically trinket but i'm having trouble with line 23 of my code, namely i'm getting a tuple/float error. "TypeError: unsupported operand type(s) for Div: 'list' and 'float' on line 23 in main.py"

Expand|Select|Wrap|Line Numbers
  1. from math import * 
  2. import numpy as np 
  3. from numpy import array
  4. import matplotlib.pyplot as plt
  5.  
  6. x = 1
  7.  
  8. time = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]
  9.  
  10. while True: 
  11.   name = input ("Enter name of isotope or type End to finish") 
  12.   if name == "End": 
  13.     break 
  14.   else: 
  15.     tau = float(input("Enter half-life of named isotope in seconds")) 
  16.     m = float(input("Enter starting mass of isotope in grams")) 
  17.     T = float(input("Enter time elapsed in seconds")) 
  18.     y = m * (exp((-log(2)) * (T / tau))) 
  19.     print "Mass of remaining isotope is", y, "g" 
  20.     Start = 5 / (exp((-log(2)) * (30 / tau))) 
  21.     print "To have 5 grams remaining after 30 s we need a starting mass of", Start, "g" 
  22.  
  23.     n = m * (exp((-log(2)) * (time / tau)))
  24.  
  25. plt.plot(t,n)
  26. plt.title("Radioactive decay rates of isotopes")
  27. plt.xlabel("Time / s")
  28. plt.ylabel("Remaining mass / g")
  29. plt.show()
May 22 '22 #1
0 9795

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Shawn | last post by:
I'm developing an e-commerc website and now that I am working on the shipping portion, I wanted to know what is the best way to get shipping rates so that they always appear current on your...
3
by: shank | last post by:
Has anyone seen a decent script for getting USPS rates live in your own shopping cart?
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
4
by: Marc Schellens | last post by:
Is there a standard way of determining the number of digits a float needs (base 10) to be printed (the integer part)? log10 is too expensive. As is a loop dividing by 10. I could think of...
1
by: Zurghew | last post by:
Hello all, I have just created a database (partially) which will bill customers for work done. However I am stuck when it is comes to different rates for different works. REQUIRED: What I...
3
by: michb | last post by:
I need to be able to calculate on a daily basis, both normal and overtime hours for both payroll and job costing. I also then need to calculate the above on a weekly basis, in order to complete...
9
by: Nicolas Blais | last post by:
Hi, I have this following class which I use as a timer: #include <sys/time.h> using namespace std; class chrono { public: chrono() {};
1
by: gareth | last post by:
Hello I am looking for some help with table structure design, i am creating a database which manages data on loft and cavity wall insulation done by various contractors. The database uses look up...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.