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
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.
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 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 experimenting with pointers in C. I wrote this code. int i1; int i2 =...
I am experimenting with pointers in C. I wrote this code. int i1; int i2 = 50; int *intptr1; int *intptr2; intptr1 = &i1; intptr2 = &i2; intptr1 = intptr2; printf("\nvalue of intptr1: %d\n", *intptr1); /*prints 50*/ dubptr1 = (double *)intptr1; printf("\nvalue of dubptr1: %f\n", *dubptr1); /*prints 0.0000*/ I would have expected the last statement to print 50.0000. Is it actually supposed to print 0.0000 or did I make a mistake somewhere and if I did please help me understand...
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); } }
I am using matlab and getting a "matrix dimensions error below" for line 22. Can someone...
I am using matlab and getting a "matrix dimensions error below" for line 22. Can someone spot the error and try the code to fix the error. %The beginning step is to generate a functionf(t) that consists of the sum %of the following components % 25 Hz cosine function of magnitude 1 % 50 Hz sine function of magnitude 1 % 40 Hz square wave function of magnitude 1 clear; clc; close all; %sample rate is given at 2500 Hz...
I am stuck on these problems and need a explanation as to why i keep getting...
I am stuck on these problems and need a explanation as to why i keep getting them wrong/ what the answer is H0:  1 -  2= 0 Ha:  1 -  2≠ 0 The following results are from independent samples taken from two populations. Sample 1 Sample 2 n 1 = 35 n 2 = 40 x 1 = 13.6 x 2 = 10.1 s 1 = 5.8 s 2 = 8.2 a. What is the value of the test statistic (to 2 decimals)? b....
For some reason I followed the steps in my project and I am getting the incorrect...
For some reason I followed the steps in my project and I am getting the incorrect output and when I am submitting it, it gives me compilation error. Printing empty array -- next line should be blank Testing append: Shouldn't crash! Should print 100 through 110 below, with 110 on a new line: 100 101 102 103 104 105 106 107 108 109 110 Checking capacity of new array: OK Append test #2: Should print 100 through 120 below, on...
what did i do wrong in here? error said I have wrong code for scatter(rate(:,1),rate(:,5),'o') but...
what did i do wrong in here? error said I have wrong code for scatter(rate(:,1),rate(:,5),'o') but when I solved it, other codes are messed up how to solve it? datacell = textscan( regexprep( fileread('cricketData.csv'), '\$', '0' ), '%f%f', 'delimiter', ',', 'HeaderLines', 1); Duration = datacell{1}; Input = datacell{1}; YourTable = table(Duration, Input); temp=datacell(:,1); rate=datacell(:,2); scatter(rate(:,1),rate(:,5),'o') xlabel('temperature(T in degrees Fahrenheit)') ylabel('chirping (R in chirp per second))') title('Chirping rate vs Temperature') p=polyfit(rate(:,1),rate(:,2),1); x=min(1)-2:.01:max(2)+2; hold on plot(x,polyval(p,x)) legend('Data points,''best fit equation') fprintf('Calculated equation:...
DataTable 1 Focal length, f 1.76 2f 3.52 Height of object, ho 4.0 Data Table 2...
DataTable 1 Focal length, f 1.76 2f 3.52 Height of object, ho 4.0 Data Table 2 General Description Object Dist. (cm) Image Dist. (cm) Object Size (cm) Image Size (cm) Other Observations (real, virtual or no image?) (Upright or inverted image?) Object about 5 f 10 74.04 4 -29.62 Real, inverted Object about 2.5f 10 7.87 4 -3.15 Real, inverted Object 2f 10 5.44 4 -2.18 Real, inverted More than f and less than 2f 10 4.29 4 -1.71 Real,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT