Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Follow publication

Member-only story

8 Useful Built-in Python Functions For Beginners

Liu Zuo Lin
Level Up Coding
Published in
3 min readDec 17, 2023

Day 43 of experimenting with video content

1) print()

print('apple')
print('orange')
print('pear')

# apple
# orange
# pear

When we put something in print(), it gets printed to our terminal (also known as standard output)

2) abs()

print(abs(-5))  # 5
print(abs(6)) # 6

abs() gives us the absolute value of a number. In other words, negative numbers become positive, while positive numbers remain positive.

3) input()

The input() function allows us to ask our users to enter something into our Python program.

name = input('what is your name? ')
print('your name is ' + name)

# what is your name? tom
# your name is tom

Note that input() always always returns a string value. So if you want numbers or anything else, you need to do your own necessary type conversion.

4) range()

range() as part of a for loop allows us to repeat code actions multiple times. Without having to copy and paste our code multiple times.

for i in range(5):
print('apple')

# apple
# apple
# apple
# apple
# apple

5) dir()

x = 'apple'
print(dir(x))

# ['__add__', '__class__', '__contains__', '__delattr__',
# '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
# '__getattribute__', '__getitem__', '__getnewargs__',
# '__getstate__', '__gt__', '__hash__', '__init__',
# '__init_subclass__', '__iter__', '__le__', '__len__',
# '__lt__', '__mod__', '__mul__', '__ne__', '__new__',
# '__reduce__', '__reduce_ex__', '__repr__', '__rmod__',
# '__rmul__', '__setattr__', '__sizeof__', '__str__',
# '__subclasshook__', 'capitalize', 'casefold',
# 'center', 'count', 'encode', 'endswith', 'expandtabs',
# 'find', 'format', 'format_map', 'index', 'isalnum'…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Write a response