Computer Science, asked by Chhatrshal, 8 months ago

6
s statement?
Identify the data types
3, 13.0,"13", 3j​

Answers

Answered by ssbiradar2005
2

Explanation:

integers with a fixed size, because it stores many of them together and needs to calculate with them efficiently. Numpy data types include a range of integer types named for their size, so e.g. int16 is a 16-bit integer, with 216 possible values.

Integer types can also be signed or unsigned. Signed integers allow positive or negative values, unsigned integers only allow positive ones. For instance:

uint16 (unsigned) ranges from 0 to 216−1

int16 (signed) ranges from −215 to 215−1

Floating Point numbers

A string containing a floating point number can be converted into a floating point number using the float() command:

a = '35.342'

b = float(a)

b

35.342

type(b)

float

Complex numbers

Python (as Fortran and Matlab) has built-in complex numbers. Here are some examples how to use these:

x = 1 + 3j

x

(1+3j)

abs(x) # computes the absolute value

3.1622776601683795

x.imag

3.0

x.real

1.0

x * x

(-8+6j)

x * x.conjugate()

(10+0j)

3 * x

(3+9j)

Note that if you want to perform more complicated operations (such as taking the square root, etc) you have to use the cmath module (Complex MATHematics):

import cmath

cmath.sqrt(x)

(1.442615274452683+1.0397782600555705j)

Functions applicable to all types of numbers

The abs() function returns the absolute value of a number (also called modulus):

a = -45.463

abs(a)

45.463

Note that abs() also works for complex numbers (see above).

Sequences

Strings, lists and tuples are sequences. They can be indexed and sliced in the same way.

Tuples and strings are “immutable” (which basically means we can’t change individual elements within the tuple, and we cannot change individual characters within a string) whereas lists are “mutable” (.i.e we can change elements in a list.)

Sequences share the following operations

`a[i]` returns *i*-th element of `a`

`a[i:j]` returns elements *i* up to *j* − 1

`len(a)` returns number of elements in sequence

`min(a)` returns smallest value in sequence

`max(a)` returns largest value in sequence

`x in a` returns `True` if `x` is element in `a`

`a + b` concatenates `a` and `b`

`n * a` creates `n` copies of sequence `a`

Sequence type 1: String

Further information

Introduction to strings, Python tutorial 3.1.2

A string is a (immutable) sequence of characters. A string can be defined using single quotes:

a = 'Hello World'

double quotes:

a = "Hello World"

or triple quotes of either kind

a = """Hello World"""

a = '''Hello World'''

The type of a string is str and the empty string is given by "":

a = "Hello World"

type(a)

str

b = ""

type(b)

str

type("Hello World")

str

type("")

str

The number of characters in a string (that is its length) can be obtained using the len()-function:

a = "Hello Moon"

len(a)

10

a = 'test'

len(a)

4

len('another test')

12

You can combine (“concatenate”) two strings using the + operator:

'Hello ' + 'World'

'Hello World'

Strings have a number of useful methods, including for example upper() which returns the string in upper case:

extra comma is required to distinguish (42,) from (42)

Answered by sonydhaliwal629
1

Answer:

jdokduvjvvysyzGz uig.

Similar questions