-
In the below elements which of them are values or an expression? eg:- values can be integer or string and expressions will be mathematical operators. (a) * :- expressions (b) 'hello' :- values (c) -87.8 :- values (d) - : - expressions (e) / : - expressions (f) + :- expressions (g) 6 :- values
-
What is the difference between string and variable? (a) String- String are sequences/group of character data. (b) Variable- variable is a named location to store data. E.g.- x="yogi" in this expression (x) is a variable and ("yogi") is a string
-
Describe three different data types. (a) String (b) Integer (c) Floats
-
What is an expression made up of? What do all expressions do? Ans:- Expression is a combination of symbols or combination operators and operands . Expression generally represents values
-
This assignment statements, like spam = 10. What is the difference between an expression and a statement? Ans:- Every expression is a statement but every statement is not an expression. Expression only represents values and every executed line in the code called statement perhaps it will not produce any value.
-
After running the following code, what does the variable bacon contain? bacon = 22 bacon + 1 output:- print(bacon) 23
-
What should the values of the following two terms be? 'spam' + 'spamspam' Output:- print("spam"+"spamspam") spamspamspam 'spam' * 3 Output:- print("spam"*3) spamspamspam
-
Why is eggs a valid variable name while 100 is invalid? Ans:- Because a variable could not start from a number.
-
What three functions can be used to get the integer, floating-point number, or string version of a value? Ans:- For Integer int() function is used to converts the value into an integer number. For Floating-point number float() function is used to converts the value into an floating-point number. For String str() function is used to converts the value into an string.
-
Why does this expression cause an error? How can you fix it? 'I have eaten ' + 99 + ' burritos.' Ans:- Because python can only concatenate str (not "int") to str. We can fix this with F string. print(f"I have eaten {99} burritos.") I have eaten 99 burritos.