Commit 3c77befa authored by Raju Devidas's avatar Raju Devidas
Browse files

practice of python in a crash course format

parents
{
"python.pythonPath": "/bin/python3.10"
}
\ No newline at end of file
print(10 / 3)
print(10 // 3)
print(10 % 3)
print(10 ** 3)
x = 10
x = x + 3
x += 3
\ No newline at end of file
# first = input("First: ")
# second = input("Second: ")
# sum = float(first) + float(second)
# print("Sum: " + str(sum)
first = float(input("First: "))
second = float((input("Second: ")))
sum = float(first) + float(second)
print("Sum: " + str(sum))
x = 3 > 2
print(x)
y = 3 < 2
print(y)
z = 3 == 2
print(z)
a = 3 != 2
print(a)
\ No newline at end of file
weight = float(input("Weight: "))
convert_in = input("(K)g or (P)s:")
if convert_in == "p" or convert_in == "P":
weight_in_pounds = weight / 2.204623
print("Weight in Pounds: " + str(weight_in_pounds))
elif convert_in == "k" or convert_in == "K":
weight_in_Kilos = weight / 0.4535924
print("Weight in Kilos: " + str(weight_in_Kilos))
else:
print("Invalid Input")
first_name = "John"
last_name = "Smith"
age = 20
is_patient_a_new_patient = True
\ No newline at end of file
numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num)
item = 0
while item < len(numbers):
print(numbers[item])
item = item + 1
temperature = 50
if temperature > 30:
print("Its a hot day")
print("Drink plenty of water")
elif temperature > 20: #(20,30)
print("Its a Nice day")
elif temperature > 10:
print("Its a cold day")
else:
print("unable to get temperature")
numbers = [1, 2, 3, 4, 5]
numbers.append(6)
print(numbers)
numbers.insert(0, -1)
print(numbers)
numbers.remove(3)
print(numbers)
numbers.clear()
print(numbers)
numbers = [1, 2, 3, 4, 5]
print(3 in numbers)
print(len(numbers))
names = ['John', 'Bob', 'Mosh', 'Sam', 'Marry']
print(names)
print(names[1])
print(names[-2])
names[0] = "Jon"
print(names)
print(names[0:4])
price = 5
print(price > 10 or price < 30)
\ No newline at end of file
x = (10 + 3) * 2
print(x)
\ No newline at end of file
age = 20
price = 19.95
first_name = "Raj"
is_online = True
print(age)
for number in range(10, 30, 3 ):
print(number)
\ No newline at end of file
name = input("What is your name? ")
print("Hello " + name)
\ No newline at end of file
course = "Python for beginners"
print(course.replace("be", "Be"))
print(course)
print("Python" in course)
\ No newline at end of file
numbers = (1, 2, 2, 3)
print(numbers.count(2))
\ No newline at end of file
birth_year = input("Enter your birth year")
age = 2022 - int(birth_year)
print(age)
num = 1
while num <= 8:
print((num * "*"))
num = num +1
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment