Question

why am I getting this error with this code? :print('Women: {:.2f} calories'.format('calories_woman')) THIS IS THE ERROR...

why am I getting this error with this code?

:print('Women: {:.2f} calories'.format('calories_woman'))

THIS IS THE ERROR I AM GETTING

:ValueError: Unknown format code 'f' for object of type 'str'

Homework Answers

Answer #1

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

Here is the issue.

You are using .f for the str type. here 'calories_woman' is string , Hence format should be s not the f.

Something like below

But if you are trying  to print value instread of string. You have to use variable of double type like below

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am trying to print an essay in my python code but the words keep getting...
I am trying to print an essay in my python code but the words keep getting cut over two lines. How can i fix this using python code so that it is formatted nicely? thanks
What's wrong with this code? #Java Why I am getting error in : int BusCompare =...
What's wrong with this code? #Java Why I am getting error in : int BusCompare = o1.numberOfBusinesses.compareTo(o2.numberOfBusinesses); public class TypeComparator implements Comparator<Type> { @Override public int compare(Type o1, Type o2) { // return o1.name.compareTo(o2.name); int NameCompare = o1.name.compareTo(o2.name); int BusCompare = o1.numberOfBusinesses.compareTo(o2.numberOfBusinesses); // 2-level comparison using if-else block if (NameCompare == 0) { return ((BusCompare == 0) ? NameCompare : BusCompare); } else { return NameCompare; } } } public class Type implements Comparable<Type> { int id; String name; int...
i am having trouble with the print function working. I need the output to say “in...
i am having trouble with the print function working. I need the output to say “in (y) easter is on month (n) and day (p)” right now i have print(“ In “ + str (y) “Easter is on month “ + str(n) + “ and day “ + str (p)) but this is producing a syntax error
Java code. I want to display the print at a format as 00:00:00.
Java code. I want to display the print at a format as 00:00:00.
Using Python (pandas as pd) I am trying to use the split, apply, combine method but...
Using Python (pandas as pd) I am trying to use the split, apply, combine method but am getting an "invalid syntax" error at the end of the line that says "for days_name, days_df in grouped_by_day" I declared grouped_by_day in the split function but did not get any errors so I am not sure what happened or how to fix it. Below is a copy of the split, apply, combine section of my code. mean_data_ser = pd.Series() #split grouped_by_day= days_df.groupby("Day of...
This is an example out of my text which I copied directly but am getting an...
This is an example out of my text which I copied directly but am getting an error every iteration and am unsure how to correct it. The error is " the condition has length > 1 and only the first element will be used" and my code is: f <- function(x, sigma) { if (any(x < 0)) return(0) stopifnot(sigma > 0) return((x/sigma^2)*exp(-x^2 / (s*sigma^2))) } xt <- x[i-1] y <- rchisq(1, df = xt) m <- 10000 sigma <- 4...
I am working on exercise 5.30 from Introduction to Computing using python (Author: Perkovic). I was...
I am working on exercise 5.30 from Introduction to Computing using python (Author: Perkovic). I was looking at the solution and was able to understand what to do. However, when I implement the temp function as indicated, I keep getting this error "ValueError: the first two maketrans arguments must have equal length". However, it seems my two arguments are equal length, so I'm not sure what I am doing wrong! print('Exercise 5.30') def many(file): infile = open(file) content = infile.read()...
I keep getting error working on my project 2 MAT 243. What am I doing wrong?...
I keep getting error working on my project 2 MAT 243. What am I doing wrong? Step 3: Hypothesis Test for the Population Mean (I) A relative skill level of 1420 represents a critically low skill level in the league. The management of your team has hypothesized that the average relative skill level of your team in the years 2013-2015 is greater than 1420. Test this claim using a 5% level of significance. For this test, assume that the population...
I am having a problem with this one error. I have to turn this in tonight...
I am having a problem with this one error. I have to turn this in tonight and this is holding me up right now. Just not sure how to fix it. .VS 2019 .net framework windows forms private void DisplayForm_Load(object sender, EventArgs e) { if (File.Exists("Employee.txt")) { using (StreamWriter sr = new StreamWriter("employee.txt")) { string employeeId = ""; while ((employeeId = sr.ReadLine()) != null) { Employee employee = new Employee(employeeId, sr.ReadLine(), decimal.Parse(sr.ReadLine()), decimal.Parse(sr.ReadLine())); Employee emp = employee; employeeListBox.Items.Add(emp); allEmployee.Add(emp); }...
I am getting an "invalid operands to binary" error for the lines "pp->element == value" and...
I am getting an "invalid operands to binary" error for the lines "pp->element == value" and "pp->left->element > value". int insert(NodeT **pp, Element value) { if (pp->element == value) { return 0; } else if (pp->left->element > value) { pp->left = allocateNode(value); } else { pp->right = allocateNode(value); } }