How many types of literals are allowed in c




















By Priya Pedamkar. The value which is assigned to the constant variable is called literals. The constant value can be named differently as literal. Each of the above mentioned different types of literals is explained below along with its example code:.

Integer literals are represented mainly in two ways: prefix and suffix. Decimal-literal in base This represents value in decimal 0,1,2,3,4,5,6,7,8,9 digits. The value must start with non-zero decimal digit. Binary-literal in base 2: This represents value in binary 0,1 digits. There are several ways to use integer literals in your code. You can specify a literal with decimal, octal, or hexadecimal base. To specify an integer in decimal base you can simply use it as shown below. All the values by default are displayed in decimal base.

To set base for cout output you can use setbase function. But before it you need to add the following include line:. We can also specify a literal of type long and unsigned. A floating point literal consist of decimal values fractional value that can be followed by the exponent part if you want.

For example: , , Hex-literal base 16 : 0x or 0X followed by one or more hexadecimal digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, A, b, B, c, C, d, D, e, E, f, F. For example: 0b, 0B Suffixes: The Prefix of the integer literal indicates the type in which it is to be read. For example: LL indicates a long long integer value because of the suffix LL These are represented in many ways according to their data types. Example: C. Skip to content.

Change Language. Related Articles. Table of Contents. Lists are mutable objects that can contain any Python data. They are generally used for small collectioin of data. Question 8: What is used to represent Strings in Python? All white space i. You can use single quotes and double quotes freely within the triple quotes. This is the first line. This is the second line. Question 9: Is there a tool help to find bugs or perform static analysis?

Answer: Yes, pychecker is a static analysis tool that finds bugs in Python source case and warns about code complexity and style. Pylint is another tool that checks if a module satisfies a coding standard, and also make it possible to write plug-ins to add a custom feature.

Question Which of the following variable names are invalid? Why are they called so? Answer: The four basic data types are :. Question Classify the Python data types. Your email address will not be published. Notify me of follow-up comments by email. Notify me of new posts by email. Created with Sketch. Class 11 Computer Science Python. Short Answer type Questions [2 mark each] Question 1: What is the difference between a keyword and an identifier?

Python allow five types of literals : String literals Numeric literals Boolean literals Special literal None Literal collections like tuples, lists etc.

Answer: Python allows three types of integer literals : Decimal base 10 integer literals. Octal base 8 integer literals. Hexadecimal base 16 integer literals. For example, decimal 12 will be written as 14 as octal integer and as OXC as hexa decimal integer.

Answer: Python allows two string types : Single line strings : Strings that are terminated in single line.

No special character other than under-score should be included in the identifier. No reserved word or standard identifier should be used. Upper and lower case letters are different. All characters are significant. Answer: a Numbers b String c List d Tuple e Dictionary Question Write a list comprehension that builds a list of the even numbers from 1 to 10 inclusive.

Dictionary is indexed by keys. Dictionary is similar to association array or hash table of other languages. Long Answer type Questions [4 mark each] Question 1: How do we share global variables across modules in Python? Function Description int x [, base] Converts x to an integer, base specifies the base if x is a string.

These are called so because : Number data type stores numerical values and is immutable i. Three types of sequence data type available in Phyton are strings, lists and tuples.

Sets in an unordered collection of values of any type, with no duplicate entry. Sets are immutable.



0コメント

  • 1000 / 1000