diff --git a/01_Day_Introduction/helloworld.py b/01_Day_Introduction/helloworld.py index d8007868f..2704fb856 100644 --- a/01_Day_Introduction/helloworld.py +++ b/01_Day_Introduction/helloworld.py @@ -9,8 +9,8 @@ print(3 + 2) # addition(+) print(3 - 2) # subtraction(-) print(3 * 2) # multiplication(*) -print(3 / 2) # division(/) print(3 ** 2) # exponential(**) +print(3 / 2) # division(/) print(3 % 2) # modulus(%) print(3 // 2) # Floor division operator(//) @@ -22,4 +22,7 @@ print(type('Asabeneh')) # String print(type([1, 2, 3])) # List print(type({'name': 'Asabeneh'})) # Dictionary -print(type({9.8, 3.14, 2.7})) # Tuple +print(type({9.8, 3.14, 2.7})) # Set +print(type((9.8, 3.14, 2.7))) # Tuple +print(type(True)) # Bool +print(type(None)) # NoneType diff --git a/02_Day_2/variables.py b/02_Day_2/variables.py new file mode 100644 index 000000000..4a3837c98 --- /dev/null +++ b/02_Day_2/variables.py @@ -0,0 +1,13 @@ +# Day 2: 30 Days of Python Programming + +first_name = "Bhratesh" +Last_name = "Dhangar" +Full_name = "Bhratesh Dhangar" +Country_name = "India" +City_name = "Pune" +Age = 27 +Year = 2024 +Is_married = False +Is_true = True +Is_light_on = True +First_name, Last_name, Age = "Bhratesh", "Dhangar", 27 \ No newline at end of file diff --git a/03_Day_Operators/day-3.py b/03_Day_Operators/day-3.py index cbf7e5a1d..b3055f6b6 100644 --- a/03_Day_Operators/day-3.py +++ b/03_Day_Operators/day-3.py @@ -1,26 +1,26 @@ # Arithmetic Operations in Python # Integers -print('Addition: ', 1 + 2) -print('Subtraction: ', 2 - 1) -print('Multiplication: ', 2 * 3) +print(f'Addition: {1 + 2}') +print(f'Subtraction: {2 - 1}') +print(f'Multiplication: {2 * 3}') # Division in python gives floating number -print('Division: ', 4 / 2) -print('Division: ', 6 / 2) -print('Division: ', 7 / 2) +print(f'Division: {4 / 2}') +print(f'Division: {6 / 2}') +print(f'Division: {7 / 2}') # gives without the floating number or without the remaining -print('Division without the remainder: ', 7 // 2) -print('Modulus: ', 3 % 2) # Gives the remainder -print('Division without the remainder: ', 7 // 3) -print('Exponential: ', 3 ** 2) # it means 3 * 3 +print(f'Division without the remainder: {7 // 2}') +print(f'Modulus: {3 % 2}') # Gives the remainder +print(f'Division without the remainder: {7 // 3}') +print(f'Exponential: {3 ** 2}') # it means 3 * 3 # Floating numbers -print('Floating Number,PI', 3.14) -print('Floating Number, gravity', 9.81) +print(f'Floating Number, PI: {3.14}') +print(f'Floating Number, gravity: {9.81}') # Complex numbers -print('Complex number: ', 1+1j) -print('Multiplying complex number: ', (1+1j) * (1-1j)) +print(f'Complex number: {1+1j}') +print(f'Multiplying complex number: {(1+1j) * (1-1j)}') # Declaring the variable at the top first @@ -38,13 +38,13 @@ # I should have used sum instead of total but sum is a built-in function try to avoid overriding builtin functions print(total) # if you don't label your print with some string, you never know from where is the result is coming -print('a + b = ', total) -print('a - b = ', diff) -print('a * b = ', product) -print('a / b = ', division) -print('a % b = ', remainder) -print('a // b = ', floor_division) -print('a ** b = ', exponential) +print(f'a + b = {total}') +print(f'a - b = {diff}') +print(f'a * b = {product}') +print(f'a / b = {division}') +print(f'a % b = {remainder}') +print(f'a // b = {floor_division}') +print(f'a ** b = {exponential}') # Declaring values and organizing them together num_one = 3 @@ -58,24 +58,24 @@ remainder = num_two % num_one # Printing values with label -print('total: ', total) -print('difference: ', diff) -print('product: ', product) -print('division: ', div) -print('remainder: ', remainder) +print(f'total: {total}') +print(f'difference: {diff}') +print(f'product: {product}') +print(f'division: {div}') +print(f'remainder: {remainder}') # Calculating area of a circle radius = 10 # radius of a circle # two * sign means exponent or power area_of_circle = 3.14 * radius ** 2 -print('Area of a circle:', area_of_circle) +print(f'Area of a circle: {area_of_circle}') # Calculating area of a rectangle length = 10 width = 20 area_of_rectangle = length * width -print('Area of rectangle:', area_of_rectangle) +print(f'Area of rectangle: {area_of_rectangle}') # Calculating a weight of an object mass = 75 @@ -99,22 +99,24 @@ print(len('python') > len('dragon')) # False # Boolean comparison -print('True == True: ', True == True) -print('True == False: ', True == False) -print('False == False:', False == False) -print('True and True: ', True and True) -print('True or False:', True or False) +print(f'True == True: {True == True}') +print(f'True == False: {True == False}') +print(f'False == False: {False == False}') +print(f'True and True: {True and True}') +print(f'True or False: {True or False}') # Another way comparison +# 'is' checks for object identity, while '==' checks for value equality. +# For comparing values (like numbers), it is safer to use '=='. # True - because the data values are the same -print('1 is 1', 1 is 1) -print('1 is not 2', 1 is not 2) # True - because 1 is not 2 -print('A in Asabeneh', 'A' in 'Asabeneh') # True - A found in the string -print('B in Asabeneh', 'B' in 'Asabeneh') # False -there is no uppercase B +print(f'1 is 1: {1 is 1}') +print(f'1 is not 2: {1 is not 2}') # True - because 1 is not 2 +print(f"'A' in 'Asabeneh': {'A' in 'Asabeneh'}") # True - A found in the string +print(f"'B' in 'Asabeneh': {'B' in 'Asabeneh'}") # False -there is no uppercase B # True - because coding for all has the word coding -print('coding' in 'coding for all') -print('a in an:', 'a' in 'an') # True -print('4 is 2 ** 2:', 4 is 2 ** 2) # True +print(f"'coding' in 'coding for all': {'coding' in 'coding for all'}") +print(f"'a' in 'an': {'a' in 'an'}") # True +print(f'4 is 2 ** 2: {4 is 2 ** 2}') # True, but using '==' is recommended for value comparison print(3 > 2 and 4 > 3) # True - because both statements are true print(3 > 2 and 4 < 3) # False - because the second statement is false