Begin your COMMANDS!

🐍 NEED TO KNOW THINGS ABOUT PYTHON 🐍

These are among the first commands most beginners learn because they cover the basics of Python.

These functions form the foundation for most beginner Python programs and are a great starting point before learning topics such as loops, conditions, functions, and graphical user interfaces with Tkinter.

💜 print() – Display Output

name = "Alice"

print("Hello!")
print("Welcome", name)

Output

Hello!
Welcome Alice

💜 input() – Accept User Input

name = input("Enter your name: ")

print("Hello", name)

Example

Enter your name: David
Hello David

💜 int() – Convert to Integer

age = int(input("Enter your age: "))

print("Next year you will be", age + 1)

Example

Enter your age: 18
Next year you will be 19

💜 float() – Convert to Decimal Number

price = float(input("Enter the price: "))

print("Price entered:", price)

Example

Enter the price: 99.95
Price entered: 99.95

💜 len() – Find the Length

word = input("Enter a word: ")

print("Number of letters:", len(word))

Example

Enter a word: Python
Number of letters: 6

💜 type() – Check the Data Type

number = 25

print(type(number))

Output

<class 'int'>

💜 range() – Generate a Sequence of Numbers

for i in range(1, 6):
    print(i)

Output

1
2
3
4
5

💜 round() – Round a Decimal Number

number = 8.6789

print(round(number, 2))

Output

8.68

💜 max() – Find the Largest Value

marks = [75, 90, 82, 68]

print("Highest marks:", max(marks))

Output

Highest marks: 90

💜 min() – Find the Smallest Value

temperatures = [32, 28, 35, 30]

print("Lowest temperature:", min(temperatures))

Output

Lowest temperature: 28

💜 str() – Converts a value into text (a string).

score = 95

message = "Your score is " + str(score)

print(message)

Output

Your score is 95

Try writing some creative programs using these and let your imagination run wild!!!!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top