DEV Community

Cover image for Basics of Python(Part 1)
SamontiBRACU
SamontiBRACU

Posted on

Basics of Python(Part 1)

There are tons of built-in functions in python which makes it more advanced and up to date language.Python has now become on of the most used programming languages than Java or C language. Although Java is preferred in some particular coding is sides but Python is best suitable.

Some common built-in Functions of Python that you need know as a beginner and how they work is as follows:

print() function

print() function is used to print a specific block of characters.

input="Hello! I am a xyz."
print(input)
Enter fullscreen mode Exit fullscreen mode

The output will look like-

Hello! I am a xyz.
Enter fullscreen mode Exit fullscreen mode

Adding strings before we print something

So here comes the question ,what is string?Strings are basically a collection of character. If we store Hello in a variable; here, variable is a collection of character and H,e,l,l,o are each a character.

If we want to add string before we print the output we can do it in the following way-

input="Hello!I am a xyz."
print("Output is:",input)
Enter fullscreen mode Exit fullscreen mode

The output will look like-

Output is:Hello!I am a xyz.
Enter fullscreen mode Exit fullscreen mode

Uppercase and lowercase function

Python recognises uppercase and lowercase characters differently.To convert a string of uppercase letters to lowercase -

input="HELLO"
print(input.lowercase())
Enter fullscreen mode Exit fullscreen mode

The output will look like-

hello
Enter fullscreen mode Exit fullscreen mode

To convert a string of lowercase letters to uppercase-

input="hello"
print(input.uppercase())
Enter fullscreen mode Exit fullscreen mode

The output will look like-

HELLO
Enter fullscreen mode Exit fullscreen mode

To remove unwanted space

input="hello I am xyz."
print(input.strip())
Enter fullscreen mode Exit fullscreen mode

The output will look like-

helloIamxyz.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)