0

Check description, something is wrong in my code?

https://code.sololearn.com/cmsJg7vnH1DE/?ref=app I am making a program in which you will see your marks but while making social studies we need to add both history and geography and both should be in float as they marks but while printing the last line it is showing it should be in string not in float. Please someone guide me what to do here, i am not able to understand why it is happening in social studies only?

22nd Jul 2020, 1:15 PM
<k>Kartik</k>
9 Réponses
+ 6
There is no need to convert data for output. And you don't need to generate a string first and then print it. python print can do this, just using comma as separator. print("Total Marks In Social Science = ",s_science,'/',100) # or it can be done with f-string (recommended !!!) print(f"Total Marks In Social Science = {s_science:.0f}/100")
22nd Jul 2020, 2:05 PM
Lothar
Lothar - avatar
+ 4
Change last 19 line as social_science = "Total Marks In Social Science = "+str(s_science)+"/100" here error occurred due to str cannot be added with float.
22nd Jul 2020, 1:22 PM
Sâñtôsh
Sâñtôsh - avatar
+ 4
you need to convert the variables to a string before you can concatenate them with another string. use str( ) ie: social_science = "Total Marks In Social Science = "+ str(s_science) +"/"+"100"
22nd Jul 2020, 1:23 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
kartik dhingra because you are using the input variables not the converted ones. input in python is treated as string unless you convert it to float or integer.
22nd Jul 2020, 10:10 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
Lothar but above in mathematics and science it is working as a float but why it is not working in last?
22nd Jul 2020, 6:53 PM
<k>Kartik</k>
0
Bahha🐧 but above in mathematics and science it is working as a float but why it is not working in last?
22nd Jul 2020, 6:53 PM
<k>Kartik</k>
0
♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ but above in mathematics and science it is working as a float but why it is not working in last?
22nd Jul 2020, 6:53 PM
<k>Kartik</k>
0
Såñtösh Màràvi[Inactive] but above in mathematics and science it is working as a float but why it is not working in last?
22nd Jul 2020, 6:53 PM
<k>Kartik</k>