Sep 10, 2024
a = 10b = 20*input() function can be used to take user inputs for name and age.
name = input("Enter your name:")print("My name is", name)print(f"My age is {age}")c = a * b * dif income > 7000:
print("Eligible for scholarship")
else:
print("Not eligible for scholarship")
a % bif num % 2 == 0:for i in range(1, 11): to iterate from 1 to 10.while i < 5: to continue until i reaches 5.numbers = [1, 2, 3, 4, 5]numbers[0]def keyword to encapsulate code.
def add(a, b):
return a + b
class Dog:
def bark(self):
print("Woof!")
my_dog = Dog()try and except for error handling.
try:
x = int(input("Enter a number:"))
except ValueError:
print("Invalid input, please enter a number.")
open(), read(), and write().
with open('file.txt', 'w') as f:
f.write('Hello World')