Advertisement

How to write your first program in python | Start your journey with python

 How do you display hello world program in python?


The easiest way to display anything on the output screen in the python programming screen is by using the print() function. To print hello world, we can design a python hello world program that prints "Hello World" to the output screen using the print() function.

Source code-               

# Python program 'Hello world'
print ("Hello World")

                

output:         

Hello world


python for beginners



What is Hello world in Python?


Printing hello world in any programming language is the simplest line of code. It's a basic line of code that's probably the first program any beginner runs. It is used to illustrate the syntax of a programming language.

Hello world in python is a line of code that prints the words "Hello world" to the output screen.

Syntax:
print("Anything you want to print")

Source code
print("Hello world, today is Monday")


Output:
Hello world, today is Monday

               

How to say hello name in python?


To say hello name in python we can use the print function with a string variable containing the name which is the person's name read as a string of characters called a string in python.

We can define a string variable 'name' to hold the person's name and then print it with "hello" using the print function.

We can also ask the user to enter their name and store it in the 'name' variable.

Source code                   

# Hello name program in python
#name =input("Enter your name: ")
print("Hello " + name)

               

Output:          
Hello (what ever the user entered name)


how to code in python
                

How do you greet someone in python?


Among the various applications of python programming, we can also write a simple program to greet someone.

Python is an easy to use language and allows us to define our functions. Functions in python are defined in such a way that they can perform a specific task for us by simply calling the function.

Let's see how we can define a function in python to say hello to someone.

To define a function in python we need to use def keyword.


Source code                  

# greet someone using python
#defining a function called greeting

def greeting ( name ):
    print("Hello "+name+", greetings from toppr!")
    name="Sanjana"

#uncomment the next line that takes input from the user
#name=input("Enter your name: ")
#Calling the greeting function and passing the name as a parameter

greet (name)

            

Output:                

Hi Sanjana, greetings from toppr!

               

Python is an open source programming language that is free to download worldwide. It also has a large and growing environment with a number of pre-installed packages and libraries.


to learn What is python programming language Click here

Post a Comment

0 Comments