Hey Everyone,I am Vikram Salunke and welcome to Python for InfoSec.
This is part 7 and in this post we will see Print.

So, till now we have used print many times. Let's look at that into detail.

Now as we saw earlier the parentheses are not necessary in Python 2.0

So, there are 2 ways to print

print

First, without the parentheses

And another is with parentheses

Bow how can we print variable's value into statement

Let's see in that in example

print integer

Let's see what we have done here

first, we have defined a variable

num = 10

Now we want to print that variable's value inside a statement

print("House no.%d" % num)

num is integer data, so we will use %d to print it's value

After that we will close the double quotes then we will again put % and variable's value which we want to print i.e. num

So, output is House no.10

That means we have successfully printed the variable's value for integer we used %d

Now let's see the example of a string

print string

print("My name is %s" % name)

we have defined variable name with value "vikram"

print("My name is %s" % name)

We want to print a string so, we will use %s and we will use name variable here

so, it automatically takes the value of a variable name because we have put %s there

s for string

Now let' see the example of float value

print float

num2 = 0.2

We have created a variable num2 with value 0.2

print("%f" % num2)

to print float value, we have used %f

Let's see another example of print

print

name = "vikram"

age = 24

We have created two variables name with value "vikram" and with value 24

print("I am %s and my age is %d" % (name,age))

To print integer we used %d and to print string we used %s

That's it for print

If you want to join our in person class then please click here we are doing trainings in some upcoming InfoSec conferences.
And if you have any doubts, any questions then you can tweet me @vikramsalunke20
We are uploading daily new videos on YouTube click here to subscribe.
If you want to solve the exercises on this topic those are below. Solve the exercises and check your understandings. Thank you :)