Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

f #429

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

f #429

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Python Practice/01_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is my first Python program
print ("I like pizza")
print ("It's really good!")

39 changes: 39 additions & 0 deletions Python Practice/02_Variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#Strings
first_name = "Rakesh"
print(first_name)
print(f"Hello {first_name}")
last_name = "Tiwarekar"
print(f"My name is {first_name} {last_name}")

#Integers
age = 40
print(age)
print(f"You are {age} years old")
quantity = 3
print(f"You are buying {quantity} items")
num_of_students = 20
print(f"Your class has {num_of_students} students")

#Float
price = 19.99
print(f"The price is ${price}")
gpa = 3.5
print(f"Your GPA is {gpa}")
distance = 5.5
print(f"The distance is {distance} kilometers")

#Boolean

is_student = True
print(f"Are you a student? {is_student}")
is_teacher = False
if is_student:
print("You are a student")
else:
print("You are not a student")

is_online = True
if is_online:
print("You are online")
else:
print("You are offline")
28 changes: 28 additions & 0 deletions Python Practice/03_Typecasting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#Typecasting = process of converting a variable from one data type to another data type
name= "Rakesh Tiwarekar"
age = 40
gpa = 3.5
is_student = True
type(name)
print(type(name))
print(type(age))
print(type(gpa))
print(type(is_student))

gpa=int(gpa)
print(type(gpa))
age=float(age)
print(type(age))

age=str(age) #age is now a string
print(type(age))
print(age) #age is now a string

age += "1"
print(age) #age is now a string

name = bool(name)
print(type(name)) #name is now a boolean
print(name) #name is now a boolean


10 changes: 10 additions & 0 deletions Python Practice/04_Input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#Input = A function that prompts the user for input and returns the input as a string

name = input("What is your name? :")
print(f"Hello, {name}!")


age = int(input("How old are you? :") )
age = age + 1
print("HAPPY BIRTHDAY!!!")
print(f"You are {age} years old")
48 changes: 48 additions & 0 deletions Python Practice/05_Excercise-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#Exercise 1 - Rectangle Area calculation

length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))

Area = length * width
print("The area of the rectangle is: ", Area)

print(f"The area of the rectangle is: {Area} cm2")


#Execise 2 - Shopping cart program

item = input("What item would you like to buy? ")
price=float(input("What is the price of the item? "))

quantity = int(input("How many would you like to buy? "))
total = price * quantity

print(f"The total price of {quantity} {item} is: {total} ")

print(f"You have purchased {quantity} {item} at {price} each for a total of ${total} ")


#Madlibs Game
adjective1 = input("Enter an adjective(description): ")
noun1 = input("Enter a noun(person, place, thing): ")
adjective2= input("Enter an adjective(description): ")
verb1 = input("Enter a verb ending with 'ing': ")
adjective3 = input("Enter an adjective(description): ")


print(f"Today I went to a {adjective1} zoo.")
print(f"In an exibit, I saw a {noun1}.")
print(f"{noun1} was {adjective2} and {verb1}.")
print(f"I was {adjective3}.")












62 changes: 62 additions & 0 deletions Python Practice/06_Math.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

friends = 5

#ADDITION
friends = friends + 1
print(friends)
#auguemented assignment operator
friends += 1
print(friends)

#SUBTRACTION
friends = friends -2
print(friends)
#auguemented assignment operator
friends -= 2
print(friends)

#MULTIPLICATION
friends = friends * 3
print(friends)
#auguemented assignment operator
friends *= 3
print(friends)

#DEVISION
friends = friends / 2
print(friends)
#auguemented assignment operator
friends /= 2
print(friends)

#EXPONENT
friends = friends ** 2
print(friends)

#auguemented assignment operator
friends **=2
print(friends)

#REMAINDER - Modulus operator
remainder = friends % 3
print(remainder)

#----------------------------------------------
x=3.14
y=-4
z=5

result = round(x) #rounds to the nearest whole number
print(result)

result = abs(y) #returns the absolute value of y
print(result)

result = pow(y,3) #returns y raised to the power of 3
print(result)

result = (x,y,z) #returns the largest number
print(result)

result = min(x,y,z) #returns the smallest number
print(result)
42 changes: 42 additions & 0 deletions Python Practice/06_Math02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import math #importing math module

print(math.pi)
print(math.e)

x=9
result = math.sqrt(x) #returns the square root of x
print(result)

y=9.1
result =math.ceil(y) #returns the smallest integer greater than or equal to y
print(result)

z=9.9
result = math.floor(z) #returns the largest integer less than or equal to z
print(result)


#Calculate circumference of a circle

radius = float(input("Enter the radius of the circle: "))
circumference = 2 * math.pi * radius
print(f"The circumference of the circle is {round(circumference,2)}")

#Calculate area of a circle

radius = float(input("Enter the radius of the circle: "))
area = math.pi * pow(radius,2)
print(f"The area of the circle is {round(area,2)}")

#Hytothenuse of a right angled triangle

a = float(input("Enter the length of side a: "))
b = float(input("Enter the length of side b: "))
c = math.sqrt(pow(a,2) + pow(b,2))
print(f"The length of the hypotenuse is {round(c,2)}")






44 changes: 44 additions & 0 deletions Python Practice/07_IfStatement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#if=Do some code if a condition is true
#Else=Do some code if a condition is false

age = int(input("Enter your age: "))
if age > 100:
print("You are too old to sign up.")
elif age <0:
print("You are not born yet.")
elif age >= 18:
print("You are now signed up!")
else:
print("You are not old enough to sign up.")


#Use == for comparison
response = input("Would you like food (yes/no): ")
if response == "yes":
print("Here is your food.")
else:
print("Okay, no food for you.")


name = input("What is your name: ")

if name == "":
print("You did not enter a name.")
else:
print(f"Hello, {name}!")

#Boolean
for_sale = True
if for_sale:
print("Item is for sale.")
else:
print("Item is not for sale.")

#Boolean
online = False

if online:
print("User is online.")
else:
print("User is offline.")

53 changes: 53 additions & 0 deletions Python Practice/08_Exercise-02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#python calculator


operator = input("Enter the operator (+ - * /): ")
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))

if operator == "+":
result = num1 + num2
print(round(result,3))
elif operator == "-":
result = num1 - num2
print(round(result,3))
elif operator == "*":
result = num1 * num2
print(round(result,3))
elif operator == "/":
result = num1 / num2
print(round(result,3))
else:
print(f"Invalid operator: {operator}")


# Python weight converter

weight = float(input("Enter your Weight: "))
unit = input("Kilograms or Pounds? (K or L): ")

if unit == "K":
weight = weight * 2.205
unit = "Lbs"
print(f"Your weight is {weight} and unit is {unit}")
elif unit == "L":
weight = weight / 2.205
unit = "Kg"
print(f"Your weight is {weight} and unit is {unit}")
else:
print('Invalid unit')


#Temperature Converter

unit = input("Is this temperature in Celsius or Fahrenheit? (C/F): ")
temp = float(input("Enter the temperature: "))

if unit == "C":
temp = round((9*temp) /5 + 32,1)
print(f"The temperature is {temp} degrees Fahrenheit.")
elif unit == "F":
temp = round((5*(temp-32))/9,1)
print(f"The temperature is {temp} degrees Celsius.")
else:
print(f"Invalid unit: {unit}")
28 changes: 28 additions & 0 deletions Python Practice/09_LogicalOperators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#Logical operators = evaluate multiple conditions (or, and, not)
# or = either condition is true
# and = both conditions are true
# not = reverse the result, returns False if the result is true


temp = 20
is_raining = True

if temp > 35 or temp < 0 or is_raining:
print("The outdoor event is cancelled")
else:
print("The outdoor event is not cancelled")


temp = 20
is_sunny = False

if temp >= 28 and is_sunny:
print("It is HOT outside")
elif temp <= 0 and is_sunny:
print("It is COLD outside")
elif 28 > temp > 0 and is_sunny:
print("It is WARM outside")
elif 28 > temp > 0 and not is_sunny:
print("It is CLOUDY outside")
else:
print("It is neither hot nor cold outside")
Loading