Make a program that asks for input from the user, apply eval to this input, and print out the type of the resulting object and its value. Test the program by providing five types of input: an integer, a real number, a complex number, a list, and a tuple.

Answers

Answer 1
Answer:

Answer:

x = input("Input a number ")

print(eval("x"))

print ("Type is:",type(x))

#Taking an float input

y = input("Input a number ")

print(eval("y"))

print ("Type is:",type(y))

#Taking an complex input

z = complex(input("Input a number "))

print(eval("z"))

print ("Type is:",type(z))

#Taking an List input

L_num = raw_input().split(",")

print(eval("L_num"))

print ("Type is:",type(L_num))

#Taking an tuple input.

T_num = raw_input().split(",")

print(eval("T_num"))

print ("Type is:",type(T_num))

Explanation:


Related Questions

Which statement must be included in a program in order touse a deque container?a. #include vectorb. #include c. #include containerd. #include deque
Kara's teacher asked her to create a chart with horizontal bars. Which chart or graph should she use?Bar graphColumn chartLine graphPie chart
NAT ________. allows a firm to have more internal IP addresses provides some security both allows a firm to have more internal IP addresses and provides some security neither allows a firm to have more internal IP addresses nor provides some security
Selector Next we will write a function that will help us select an output for the chatbot, based on the input it got. The overall goal of this function is to take a list of words that we got as input, a list of words to check for if they appear in the input outputs to return if something from the list to check is in the input list. Define a function, called selector. This function should have the following inputs, outputs and internal procedures: Input(s) input_list - list of string check_list - list of string return_list - list of string Output(s): output - string, or None Procedure(s): Initialize output to None Loop through each element in input_list Use a conditional to check if the current element is in check_list If it is, assign output as the returned value of calling the random.choice function on return_list Also, break out of the loop At the end of the function, return output Note that if we don't find any words from input_list that are in check_list, output will be returned as None.
Define a forest root domain.

1) The program reads an integer, that must be changed to read a floating point. 2) You will need to move that number into a floating point register and then that number must be copied into an integer register. 3) You will need to extract the exponent from the integer register and stored in another register. 4) You will need to insert the Implied b

Answers

Answer:

1. Get the number

2. Declare a variable to store the sum and set it to 0

3. Repeat the next two steps till the number is not 0

4. Get the rightmost digit of the number with help of remainder ‘%’ operator by dividing it with 10 and add it to sum.

5. Divide the number by 10 with help of ‘/’ operator

6. Print or return the sum

# include<iostream>

using namespace std;

/* Function to get sum of digits */

class gfg

{

   public:

   int getSum(float n)

   {

   float sum = 0 ;

   while (n != 0)

   {

    sum = sum + n % 10;

    n = n/10;

   }

return sum;

}

};

//driver code

int main()

{

gfg g;

float n = 687;  

cout<< g.getSum(n);

return 0;

}

Explanation:

One author states that Web-based software is more likely to take advantage of social networking (Web 2.0) approaches such as wikis and blogs. If this is the case, can we expect more social networking capabilities in all future software? Aside from LinkedIn, how can social media be leveraged by CIT graduates?

Answers

Answer:

Yes

Explanation:

I will say Yes. There are very much limitless possible and future we can expect from social media and even more from social networking. Its capabilities from upcoming software in the future. Since the Internet is in its early days of growing and cloud computing being introduced there are way more possibilities in the future.

Social media can be duely applied by CIT (Computer Information Technologies) graduates. It can be used to improve them in their career and also will helps them connect professionally. Quora is one such platform which is not exactly like LinkedIn but pretty much serves the purpose.

Define the function isEven which returns True, if a given number is even and returns False, if the number is odd. Execute the statement isEven(43) and display the output.

Answers

Answer:

Program :

#include <stdio.h> //header file

char* isEven(int number) //function

{

   if(number%2==0)

    return "True";

  else

   return "False";

}

int main() //mainfunction

{

   printf("%s",isEven(43)); //calling and display output.

   return 0; //return statement.

}

Output:

  • The above program gives as 45 output.

Explanation:

  • The above program is in c-language, The above function is used to check the number is even or odd.
  • If the number is even it returns true and if the number is odd, it returns false.
  • The print statement called that function while passing the number on the argument and print the result of the function.
  • The char* is used in return type because the function returns the string value.

Write a Comparator that compares String objects by the number of words they contain. Consider any nonwhitespace string of characters to be a word. For example, "hello" comes before "I see", which comes before "You can do it"

Answers

Answer:

import java.util.Scanner;

public class num12 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter the first String");

       String word1 = in.nextLine();

       System.out.println("Enter the second String");

       String word2 = in.nextLine();

       System.out.println("Enter the third String");

       String word3 = in.nextLine();

       //Remove all white spaces

        String cword1 = word1.replace(" ","");

       String cword2 = word2.replace(" ","");

       String cword3 = word3.replace(" ","");

       //Comparing the string by their lengths

       if(cword1.length()>cword2.length()&&cword1.length()>cword3.length()){

           System.out.println(word1+" Is the longest");

       }

       else if(cword2.length()>cword1.length()&&cword2.length()>cword3.length()){

           System.out.println(word2+" Is the longest");

       }

       else{

           System.out.println(cword3+" Is the longest");

       }

   }

}

Explanation:

Using Java Programming Language

Use the Scanner Class to obtain the String values from the user

Save them in different variables

Use the replace() method in java to remove white space from any of the string entered

Using if and else statements compare the lengths of the strings (word.length()) returns the length of the word.

Print out the word that is longest

NOTE I have compared three Strings, comparing two would have been more straigth forward

1.What is the ITIL? A.A set of process-oriented best practices B.A group of metrics that govern the program C.Focuses on value delivery D.All of the above

Answers

Information Technology Infrastructure Library(ITIL) is

  • A set of process-oriented best practices
  • A group of metrics that govern the program
  • Focuses on value delivery

Option D- All of the above

Explanation:

The process ITIL can be defined as a set of well-defined practices for the IT service management which takes concerns on aligning the IT services based on the requirements of the business.

This describes the tasks, procedures, checklists and processes that are specifically not for organization or technology but can be adapted by the business entity towards the delivering-value, strategy or handling a lower competency level.

ITIL process was developed around as a process model-based view of managing and controling the operations of the organization which is credited to W. Edwards Deming and his plan-do-chec-act (PDCA) cycle.

Develop a program that asks the user to enter a capital for a U.S. state. Upon receiving the user input, the program reports whether the user input is correct. For this application, the 50 states and their capitals are stored in a two-dimensional array in order by state name. Display the current contents of the array then use a bubble sort to sort the content by capital. Next, prompt the user to enter answers for all the state capitals and then display the total correct count. The user's answer is not case-sensitive.

Answers

Answer:try redoing everything step by step and see if that solves it

Explanation:

Other Questions