Monday, November 16, 2020

Python 3 - Tutorial

 

https://www.learnpython.org/


1

https://www.learnpython.org/en/Hello%2C_World%21

Print command

print("This line will be printed.")


2

https://www.learnpython.org/en/Variables_and_Types



Every variable in Python is an object.


Numbers

Python supports two types of numbers - integers,  floating point andcomplex numbers numbers. 


Defining integers

xrao = 9

print(xrao)



Defining floating numbers


fxrao = 9.0

print(fxrao)


varfloat = float(10)

print(varfloat)


Strings

Strings are defined either with a single quote or a double quotes.

In double quotes apostrophes can be included in the string.

Operations on numbers and strings

x = 1

y = 2

z = x + y

print(z)

output = 3


a = "Ram"

b = "bhim"

helloworld = a + " and " + b

print(helloworld)

output = Ram and bhim

Assignments can be done on more than one variable "simultaneously."


a, b = 7, 10


Mixing operators between numbers and strings in expressions is not permitted.

3

https://www.learnpython.org/en/Lists

Define a list by 

newlist = []

Add elements in the lists

newlist.append(1)

newlist.append(2)

newlist.append(3)


numbers 1,2, 3 are added as three elements in the list.


4

https://www.learnpython.org/en/Basic_Operators

5

String formatting

https://www.learnpython.org/en/String_Formatting


https://www.w3schools.com/python/


Book Contents


1.3 Types and Functions

1.4 Integer Arithmetic

1.5 & 1.8 Strings

1.6 Variables and Assignment of Values

1.7 Print Function

1.10 Input - Output











No comments:

Post a Comment