0% found this document useful (0 votes)
18 views3 pages

Python Basics: Input, Output, and Logic

Uploaded by

iam5747462
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Python Basics: Input, Output, and Logic

Uploaded by

iam5747462
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

print("Hello, World!

")

num1 = int(input("Enter first number: "))

num2 = int(input("Enter second number: "))

result = num1 + num2

print("The sum is:", result)

number = int(input("Enter a number: "))

if number % 2 == 0:

print("The number is even.")

else:

print("The number is odd.")

num1 = int(input("Enter first number: "))

num2 = int(input("Enter second number: "))

num3 = int(input("Enter third number: "))

if num1 >= num2 and num1 >= num3:

print("The largest number is:", num1)

elif num2 >= num1 and num2 >= num3:

print("The largest number is:", num2)

else:

print("The largest number is:", num3)

num = int(input("Enter a number: "))

for i in range(1, 11):

print(f"{num} x {i} = {num * i}")


text = input("Enter a word: ")

if text == text[::-1]:

print("The word is a palindrome.")

else:

print("The word is not a palindrome.")

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

operation = input("Enter operation (+, -, *, /): ")

if operation == '+':

print("Result:", num1 + num2)

elif operation == '-':

print("Result:", num1 - num2)

elif operation == '*':

print("Result:", num1 * num2)

elif operation == '/':

if num2 != 0:

print("Result:", num1 / num2)

else:

print("Division by zero is not allowed.")

else:

print("Invalid operation.")

from datetime import datetime

now = [Link]()

print("Current Date and Time:", [Link]("%Y-%m-%d %H:%M:%S"))


fruits = ["Apple", "Banana", "Cherry"]

[Link]("Orange")

print("Fruits:", fruits)

print("First fruit:", fruits[0])

for i in range(1, 21):

if i % 3 == 0 and i % 5 == 0:

print("FizzBuzz")

elif i % 3 == 0:

print("Fizz")

elif i % 5 == 0:

print("Buzz")

else:

print(i)

You might also like