Jayashree has Published 6 Articles

How do I find the largest integer less than x in Python?

Jayashree

Jayashree

Updated on 27-Oct-2022 12:23:22

3K+ Views

In this article, we will show you how to find the largest integer less than x in python. The Greatest Integer Function [X] denotes an integral part of the real number x that is the closest and smallest integer to x. It's also called the X-floor. [x]=the largest integer less ... Read More

Python: Cannot understand why the error - cannot concatenate 'str' and 'int' object ?

Jayashree

Jayashree

Updated on 13-Mar-2020 05:15:39

257 Views

This can be corrected by putting n+1 in brackets i.e. (n+1)for num in range(5):     print ("%d" % (num+1))Using %d casts the object following % to string. Since a string object can't be concatnated with a number (1 in this case) interpreter displays typeerror.

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

Jayashree

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 know Maximum and Minimum values for ints in Python?

Jayashree

Jayashree

Updated on 21-Feb-2020 12:51:33

168 Views

Python's core library has two built-in functions max() and min() respectively to find maximum and minimum number from a sequence of numbers in the form of list or tuple object.example>>> max(23,21,45,43) 45 >>> l1=[20,50,40,30] >>> max(l1) 50 >>> t1=(30,50,20,40) >>> max(t1) 50 >>> min(l1) 20 >>> min(t1) 20 >>> min(23,21,45,43) 21

How will you explain Python Operator Overloading?

Jayashree

Jayashree

Updated on 30-Jul-2019 22:30:22

309 Views

Every class in Python, whether built-in or user defined is inherited from object class. The object class has a number of properties whose name is preceded and followed by double underscores (__). Each of these properties is a wrapper around a method of same name. Such methods are called special ... Read More

What is @ operator in Python?

Jayashree

Jayashree

Updated on 30-Jul-2019 22:30:22

863 Views

@ symbol is used to define decorator in Python. Decorators provide a simple syntax for calling higher-order functions. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.we have two different kinds of decorators in Python:Function decoratorsClass ... Read More

1
Advertisements