Server Side Programming Articles - Page 2566 of 2650

How to print a value for a given key for Python dictionary?

Jayashree
Updated on 26-Feb-2020 11:22:05

7K+ Views

Python dictionary is collection of key value pairs. Value associated with a certain key is returned by get() method.>>> D1={'a':11,'b':22,'c':33} >>> D1.get('b') 22You can also obtain value by using key inside square brackets.>>> D1['c'] 33

How to convert float to integer in Python?

Gireesha Devara
Updated on 23-Aug-2023 18:42:17

2K+ Views

In python there are two number data types: integers and floats. In general integers do not have any decimal points and base value is 10 (i.e., Decimal). Whereas floats have decimal points. Python provides some built−in methods to convert floats to integers. In this article we will discuss some of them. Using the int() function The int() function converts the floating point numbers to integers, by removing the decimals and remains only the integer part. Also the int() function does not round the float values like 49.8 up to 50. Example In the example the data after the decimal ... Read More

How to convert an integer to a character in Python?

Gireesha Devara
Updated on 23-Aug-2023 18:36:02

38K+ Views

To convert an integer to a character in Python, we can use the chr() method. The chr() is a Python built−in method that returns a character from an integer. The method takes an integer value and returns a unicode character corresponding to that integer. Syntax char(number) Parameter The method takes a single integer between the range of 0 to 1, 114, 111. Return Value A unicode character of the corresponding integer argument. And it will raies a ValueError if we pass an out of range value (i, e. range(0x110000)). Also it will raise TypeError − for a non−integer argument. ... Read More

Why do we use a volatile qualifier in C++?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

520 Views

volatile means two things − The value of the variable may change without any code of yours changing it. Therefore whenever the compiler reads the value of the variable, it may not assume that it is the same as the last time it was read, or that it is the same as the last value stored, but it must be read again. The act of storing a value to a volatile variable is a "side effect" which can be observed from the outside, so the compiler is not allowed to remove the act of storing a value; for example, ... Read More

How to print out the first character of each list in Python?

Shriansh Kumar
Updated on 12-Jul-2025 23:57:50

5K+ Views

A Python list is a built-in, mutable datatype that stores multiple items or elements, separated by commas, within square brackets [ ]. The index of a list in Python starts from 0 up to length-1. We can retrieve/access elements at a particular index as follows - list_name[index] The given task is to write a Python program that prints the first character of each element in a list. But, before that, let's see some example scenarios: Scenario 1 For example, if our list contains string values, the output should be the first character of each string. Input: list = ... Read More

What is the type specifier for boolean in C++?

Govinda Sai
Updated on 26-Feb-2020 11:15:59

262 Views

The type specifier for boolean in c++ is bool. You can use it as −bool myBoolean = true;

What are type specifiers in C++?

Akansha Kumari
Updated on 23-Jul-2025 15:46:50

3K+ Views

In a statically typed language such as C++, type specifiers are keywords that are used to define the type of data that given variables will hold. There are two types of type specifiers: built-in and user-defined type specifiers. Built-in Type SpecifiersThe built-in type specifiers are the basic and predefined data types provided by C++, such as int, float, char, signed, unsigned, short, long, etc. int myNumber = 42; In this given statement, the "int" is a type specifier, which states that the variable "myNumber" can only store integer values or numeric data types. There exist a lot of built-in type specifiers in C++ ... Read More

What are type qualifiers in C++?

Akansha Kumari
Updated on 28-May-2025 19:04:29

2K+ Views

A type qualifier is a keyword in C++ that is applied to a variable, function, pointer, or parameter to add an extra feature or quality to it. For example, const int is a qualified type representing a constant integer, while int is an unqualified type, which is simply just an integer. Type qualifiers are a way of expressing additional information about a value through the type system, which ensures correctness in the use of the data. 1. The const Qualifier This is used to define a variable (or object) as constant, which means its value cannot be changed or modified ... Read More

What are Character Literals in C++?

Akansha Kumari
Updated on 04-Jun-2025 15:33:58

889 Views

In C++, character literals are the constant values, which are assigned to variables of the character data type. These values are represented by a character enclosed within single quotation marks. There are mainly five types of character literals: Narrow-character literals Wide-character literals. UTF-8 character literals UTF-16 character literals UTF-32 character literals Narrow-character Literals These character literals are of type char, which represents single-byte character. It stores characters from the ASCII table, which includes values ranging from 0 to ... Read More

What are Boolean Literals in C++?

Akansha Kumari
Updated on 02-Jun-2025 19:36:40

496 Views

Boolean Literals In C++, Boolean literals are the values, which are assigned to variables of the Boolean data type. A Boolean literal represents two values: true or false,  which are internally represented as 1 and 0 respectively. A Boolean literal occupies 1 byte (8 bits) of memory and is used for conditions, flags and logical checks. Declaring Boolean Variables  You can declare the boolean variables and assign the boolean literals to them by the given following. In this variable1 and variable2 is assigned with boolean literals true and false respectively in C++. bool variable1 = true; bool variable2 = false; ... Read More

Advertisements