Widget Recent Post No.

banner image

5 Example's Of Python Language

Python Example's

1] print("Hello, World!")

2) file = open("example.txt", "r")
contents = file.read()
print("File contents:\n", contents)
file.close()

3)3num1 = 5
num2 = 7
sum = num1 + num2
print("The sum of", num1, "and", num2, "is", sum)

4)numbers = [5, 2, 8, 3, 9, 1]
max_number = numbers[0]
for number in numbers:
    if number > max_number:
        max_number = number
print("The largest number in the list is:", max_number)

5) def factorial(n):
    if n == 0:
        return 1
    else:
        return n

5 Example's Of Python Language 5 Example's Of Python Language Reviewed by TechAdi on March 20, 2023 Rating: 5

No comments:

Powered by Blogger.