Question

For each of the following functions/operators and the given types of inputs, what will be the...

For each of the following functions/operators and the given types of inputs, what will be the type of the returned value? If you think this will always cause an error, just write "error". If you think this will sometimes cause an error, explain when it will cause an error.
Note: the examples to be analyzed for Task G contain both functions and value types that are passed to those functions.
e.g. if a line contains:
aaa(bbb)
by looking at its Python syntax, we know that aaa is the name of a function, because it is followed by an '(' i.e. open parenthesis. We can also assume that bbb has a value of a certan type, because it is notfollowed by an '(' open parentheses.
And if another line contains:
ccc ^ ddd
then we know that ccc and ddd are values that are used as input values for the '^' operator (the '^' operator performs a function that we haven't seen yet, but we're using it here just as an example).
You have to be careful, since some of these names may denote both a function as well as a value type. For example, as explained in the official Python documentation, float() and float are quite different from each other!

  1. 0. int(int)
    1. int(float)
    2. int(str)
    3. float(int)
    4. float(float)
    5. float(str)
    6. str(int)
    7. str(float)
    8. str(str)
    9. int + int
    10. int + float
    11. int + str
    12. float + float
    13. str + str
    14. int * int
    15. float * int
    16. str * int
    17. str * float
    18. int / float
    19. int / int
    20. int // int
    21. float // float

Homework Answers

Answer #1

The answer of the question is provided below, please comment if any doubts:

B.

0.int(int) => int

  1. int(float) => int
  2. int(str) => error
  3. float(int) => float
  4. float(float) =>float
  5. float(str) => error
  6. str(int) => str
  7. str(float) => error
  8. str(str) => string
  9. int + int => int
  10. int + float => float
  11. int + str => error
  12. float + float => float
  13. str + str => string
  14. int * int => int
  15. float * int => float
  16. str * int => string
  17. str * float => error
  18. int / float => float
  19. int / int => float
  20. int // int => int
  21. float // float => float
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
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
IntNode class I am providing the IntNode class you are required to use. Place this class...
IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is. struct IntNode { int data; IntNode *next;...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
1. Design a function called sum that will take as arguments two floating-point numbers and will...
1. Design a function called sum that will take as arguments two floating-point numbers and will return the sum of those two numbers. 2. Design a function called get_longer that will take as arguments two phrases (strings) and will return the longer of the two strings. 3. Design a function called get_hypotenuse that will take as arguments the two lengths of the short sides (a and b in the formula below) of a right-angle triangle and returns the length of...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains loops and branches. You will create a C program that prints a menu and takes user choices as input. The user will make choices regarding different "geometric shapes" that will be printed to the screen. General Comments: Your code must contain at least one of all of the following control types: nested for() loops a while() or a do-while() loop a switch() statement an...
The ability to read through Java™ code and predict the results, given specific inputs, is an...
The ability to read through Java™ code and predict the results, given specific inputs, is an extremely useful skill. For this assignment, you will be analyzing the Java™ code in the linked zip file, and predicting the results given specific input. Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document: What is the output of the program as it is written? What would the output of the program be if you...
Data Structure in C++ I keep getting the same warning, and I cant seem to fix...
Data Structure in C++ I keep getting the same warning, and I cant seem to fix it.. Can you explain to me what I am doing wrong? Warning: dlist.cc: In function 'std::ostream& operator<<(std::ostream&, dlist&)': dlist.cc:66:10: error: invalid initialization of reference of type 'std::ostream& {aka std::basic_ostream&}' from expression of type 'dlist::node*' dlist.cc: In function 'dlist operator+(dlist&, dlist&)': dlist.cc:93:8: error: invalid operands of types 'dlist::node*' and 'dlist::node*' to binary 'operator+' dlist.cc:97:8: error: could not convert 'result' from 'int' to 'dlist' My code:...
Please create a python module named homework.py and implement the functions outlined below. Below you will...
Please create a python module named homework.py and implement the functions outlined below. Below you will find an explanation for each function you need to implement. When you are done please upload the file homework.py to Grader Than. Please get started as soon as possible on this assignment. This assignment has many problems, it may take you longer than normal to complete this assignment. This assignment is supposed to test you on your understanding of reading and writing to a...
getting an error for the code below when attempting to compile . Not fully sure what...
getting an error for the code below when attempting to compile . Not fully sure what the error means and confused why I am getting the error. I know there are a of other logical errors but im just looking for the solution to this specific one right now. /tmp/ccq2rdty.o: In function `main': IntArrayPlay.cpp:(.text+0x42): undefined reference to `fillArray(int*, int&)' IntArrayPlay.cpp:(.text+0x55): undefined reference to `displayArray(int*, int&)' IntArrayPlay.cpp:(.text+0x114): undefined reference to `displayArray(int*, int&)' IntArrayPlay.cpp:(.text+0x15f): undefined reference to `displayArray(int*, int&)' collect2: error: ld...
(For Python) Evaluating Postfix Arithmetic Expressions. In this project you are to implement a Postfix Expression...
(For Python) Evaluating Postfix Arithmetic Expressions. In this project you are to implement a Postfix Expression Evaluator as described in section 7-3b of the book. The program should ask the user for a string that contains a Postfix Expression. It should then use the string's split function to create a list with each token in the expression stored as items in the list. Now, using either the stack classes from 7.2 or using the simulated stack functionality available in a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT