0% found this document useful (0 votes)
4 views2 pages

Python Task

The document outlines basic concepts of Python variables, data types, and operations. It explains string manipulation, comparison operators, and type casting, including examples for clarity. Additionally, it covers implicit type conversion and the default type of the input function.

Uploaded by

Devika Subramani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python Task

The document outlines basic concepts of Python variables, data types, and operations. It explains string manipulation, comparison operators, and type casting, including examples for clarity. Additionally, it covers implicit type conversion and the default type of the input function.

Uploaded by

Devika Subramani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON TASK -2

1) A variable in Python is a name used to store a value in memory. No need assign the type
in python instead of that we can assign using = ( Example : name =”devika”, age=25).
2) No, a variable name cannot start with number in python.
3) Data types in python : Int,float,set,complex,dictionaries,tuple,boolean

4) String concatenation was joining two or more strings together to form one string.
Example:

first_name = "Devika"

last_name = "Subramani"

full_name = first_name + " " + last_name

print(full_name)

output: Devika Subramani

5) To convert a string to uppercase we can use upper() and for the lowercase lower().
6) String slicing means taking a part of a string. Each character in a string has a position
(index) starting from 0. For example :

name = "Devika"
print(name[0:4])

Output : Devi

7) ‘= ‘assignment operator used to store the value - for example: x=10 , the value 10 is
stored to x. ‘==’comparison operator used to compare the values -for example:

x=10

print(x==10)

Output: True

8) Comparison operators are used to compare two values and return either True or False.
Equal to == Example : x=3,print(x==3) then output is True). Not equal to != Example :
print(5 != 3) output : True . Greater Than > Ex-print (10>5 ) output :True . Less than < Ex-
print (33<77) output : True. Less than or Equal to <= Ex-print(4 <= 2) output : False.
9) AND operator returns True only if BOTH conditions are True. OR operator returns True if
ANY ONE condition is True.
10) Type casting in Python means converting one data type into another data type.
11) To convert an integer to string we can use the str().
12) Implicit type conversion means automatic conversion of data types by [Link]
x = 50 # int
y = 2.5 # float
result = x + y
print(result)
print(type(result))

Output : 52.5 <class 'float'>


13) 3+4*2/(1-5)**2 – Ans ( 3+4*2/(1-5)=4 **2) ,(3+4*2/16),(3+8/16),(3+0.5)= 3.5
14) The default type of the input() function is string (str).

You might also like