Followers

Wednesday, 16 November 2022

Program to print muliple copies of string

In python we use "*" operator to create multiple copies of string. For example if we want a string value to be displayed  more than 1 time, we can use 

Syntax: string_var * n  where n = number of times to be printed

Reference of the code run in JupyterLab


Program to Concatenate two strings in Python

 String is one of the important data type in Python. String is collection of characters which are enclosed in double quotes. Here we are discussing concatenating 2 strings as below:

1. Assign first string vale to variable1

2. Assign second string value to variable 2

3. Add the two string variables using " +" operator which adds second string to end of first string1

Reference of the code run in JupyterLab 




Program to find the Numeric datatypes in Python

 In Python Programming, there are several datatypes supported. Numeric data types in python are  used to hold numeric values. There are 3 types of numeric datatypes allowed in python programming.

1.Integer

2.Float 

3.Complex.

type()  : is used to find the datatype of variable.


Reference of the code run in JupyterLab 

Monday, 14 November 2022

Program to Perform basic Arithmetic operations in Python

 In python, we do need to declare the datatype of variable in Python as in C,C++/Java. We can just assign a value to a variable name and perform the respective operation. For  example if we need to add numbers in Python we can just assign as such a=10 and b =10.  The below program describes all the allowed basic arithmetic operators in Python.

  


  1. we do not need to specify a new line character explicitly in print() function, whenever new print() function  is encountered it assumes to print in new line.
  2.  "# '  is comment line to enable the programmer for better understanding of code.

Reference of the code run in JupyterLab 



Print HELLO WORLD by storing into String Variable

 We can also print HELLOWORLD or any other user required message by storing it into another variable

                   

Reference of the code run in JupyterLab

How to print HELLO WORLD in python?

          

 Let us learn how to print "HELLO  WORLD" in python..

In python programming we use print(). The print () function print the python objects  to other standard output device. Here the python object is String which contains message "HELLO WORLD". We can enclose the string in either single quotes(' ')  or  double quotes(" "). both will give you the same output.


       Reference of the code run in JupyterLab