Python Programming

To print a sentence write down in IDLE as below and press enter.

Print ("Hello World")

Hello World


Working with variables:

message= "Hello Python World!"

print(message)

Hello Python World!

Rules and Guidelines to use variables in Python:-

1. Variable name can contain only numbers, letters , and underscores. They can start with letters and underscore but not with number.

2. Space are not allowed between two worlds but underscore can be used to separate two worlds.

3. Avoid using python keywords and function name as variable name.

Strings:

A string is simply a series of characters, anything inside quotes is considered a string in python, and you can use single or double quotes around your strings like this:

"This is a string"

'This is also a string'

Changing case in a string with methods:

name = "ada lovelace"

print(name.title())

Ada Lovelace

name = "Ada Lovelace"

print(name.upper())

ADA LOVELACE

print(name.lower())

ada lovelace

Combining or Concatenating Strings:

first_name = "ada"

last_name = "lovelace"

full_name = first_name + " " + last_name

print(full_name)

ada lovelace


first_name = "ada"

last_name = "lovelace"

full_name = first_name + " " + last_name

message = "Hello, " + full_name.title() + "!"

print(message)

Hello, Ada Lovelace!

Post a Comment

0 Comments