diff --git a/lecture20261020/floats01.py b/lecture20261020/floats01.py new file mode 100644 index 0000000..5fcfb72 --- /dev/null +++ b/lecture20261020/floats01.py @@ -0,0 +1,53 @@ + +data1 = 6. +data2 = 4. + + +print("-------------Float addition") + +result = data1 + data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float subtraction") + +result = data1 - data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float multiplication") + +result = data1 * data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float division") + +result = data1 / data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + diff --git a/lecture20261020/floats02.py b/lecture20261020/floats02.py new file mode 100644 index 0000000..17b65ac --- /dev/null +++ b/lecture20261020/floats02.py @@ -0,0 +1,53 @@ + +data1 = 6. +data2 = 4 + + +print("-------------Float addition") + +result = data1 + data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float subtraction") + +result = data1 - data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float multiplication") + +result = data1 * data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float division") + +result = data1 / data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + diff --git a/lecture20261020/inputs01.py b/lecture20261020/inputs01.py new file mode 100644 index 0000000..2c7e781 --- /dev/null +++ b/lecture20261020/inputs01.py @@ -0,0 +1,18 @@ + +data1 = input("Enter a value for data1 ") +data1 = float(data1) + +data2 = float( input("Enter a value for data2 ") ) + + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) + + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) + + +result = data1 * data2 + +print(result) \ No newline at end of file diff --git a/lecture20261020/ints01.py b/lecture20261020/ints01.py new file mode 100644 index 0000000..b2aa10e --- /dev/null +++ b/lecture20261020/ints01.py @@ -0,0 +1,13 @@ + +data1 = 6 +Data1 = 11 +DATA1 = 22 + +print("The value of data1 is ",data1) +print("The value of Data1 is ",Data1) +print("The value of DATA1 is ",DATA1) + +print("The type of data1 is ",type(data1) ) +print("The type of Data1 is ",type(Data1) ) +print("The type of DATA1 is ",type(DATA1) ) + diff --git a/lecture20261020/ints02.py b/lecture20261020/ints02.py new file mode 100644 index 0000000..c2ed652 --- /dev/null +++ b/lecture20261020/ints02.py @@ -0,0 +1,54 @@ + +data1 = 6 +data2 = 4 + + +print("-------------Integer addition") + +result = data1 + data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Integer subtraction") + +result = data1 - data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Integer multiplication") + +result = data1 * data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Integer division") + +result = data1 / data2 +result1 = int(result) + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) +print("The type of result1 is ",type(result1) ) diff --git a/lecture20261020/mixed01.py b/lecture20261020/mixed01.py new file mode 100644 index 0000000..334597b --- /dev/null +++ b/lecture20261020/mixed01.py @@ -0,0 +1,53 @@ + +data1 = 6 +data2 = 4. + + +print("-------------Float addition") + +result = data1 + data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float subtraction") + +result = data1 - data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float multiplication") + +result = data1 * data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + +print("-------------Float division") + +result = data1 / data2 + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) +print("The value of result is ",result) + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) +print("The type of result is ",type(result) ) + diff --git a/lecture20261020/outputs01.py b/lecture20261020/outputs01.py new file mode 100644 index 0000000..6d2d7f3 --- /dev/null +++ b/lecture20261020/outputs01.py @@ -0,0 +1,27 @@ + +data1 = input("Enter a value for data1 ") +data1 = float(data1) + +data2 = float( input("Enter a value for data2 ") ) + + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) + + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) + + +result = data1 + data2 + +print(result) + +print("The result is ",result) +# Wrong -- forgot braces +print(f"The result is result") + +print(f"The result is {result}") +print(f"The result is {result:.2f}") +print(f"The result is ${result:.2f}") + diff --git a/lecture20261020/squareroot.py b/lecture20261020/squareroot.py new file mode 100644 index 0000000..8a0b933 --- /dev/null +++ b/lecture20261020/squareroot.py @@ -0,0 +1,11 @@ +import math +# +data1 = float(input("Enter a number: ")) + +result = math.sqrt(data1) + +print(f"result = {result:f} ") + +result2 = result ** 2 +print(f"square of result2 = {result2:.42f} ") + diff --git a/lecture20261020/strings01.py b/lecture20261020/strings01.py new file mode 100644 index 0000000..fefbb00 --- /dev/null +++ b/lecture20261020/strings01.py @@ -0,0 +1,24 @@ + +message1 = "This is a sample message string." + +message2= 'This is another sample message string.' + +multiLineMessage = '''This is a long paragraph +of text to +display +''' + +print("message1 ") +print(type(message1)) +print(message1) + +print("message2 ") +print(type(message2)) +print(message2) + +print("multiLineMessage ") +print(type(multiLineMessage)) +print(multiLineMessage) + + + diff --git a/lecture20261020/strings02.py b/lecture20261020/strings02.py new file mode 100644 index 0000000..605697a --- /dev/null +++ b/lecture20261020/strings02.py @@ -0,0 +1,21 @@ + +message1 = "This is a sample message string." + +message2= 'This is another sample message string.' + +multiLineMessage = '''This is a long paragraph +of text to +display +''' + +print("message1 ") +print(type(message1), len(message1)) +print(message1) + +print("message2 ") +print(type(message2),len(message2)) +print(message2) + +print("multiLineMessage ") +print(type(multiLineMessage),len(multiLineMessage)) +print(multiLineMessage) \ No newline at end of file diff --git a/lecture20261020/strings03.py b/lecture20261020/strings03.py new file mode 100644 index 0000000..2d14e30 --- /dev/null +++ b/lecture20261020/strings03.py @@ -0,0 +1,67 @@ + +message1 = "This is a sample message string." + +message2= 'This is another sample message string.' + +multiLineMessage = '''This is a long paragraph +of text to +display +''' + +msg = message1 + message2 + +print("message1 ") +print(type(message1), len(message1)) +print(message1) + +print("message2 ") +print(type(message2),len(message2)) +print(message2) + +print("msg ") +print(type(msg),len(msg)) +print(msg) + +msg = message1 + " " + message2 + +print("message1 ") +print(type(message1), len(message1)) +print(message1) + +print("message2 ") +print(type(message2),len(message2)) +print(message2) + +print("msg ") +print(type(msg),len(msg)) +print(msg) + +print("\n") + + +msg = message1 * 3 + +print("message1 ") +print(type(message1), len(message1)) +print(message1) + +print("message2 ") +print(type(message2),len(message2)) +print(message2) + +print("msg ") +print(type(msg),len(msg)) +print(msg) + +borderStars = "*" * 60 +print(borderStars) + +borderMain = "*" + " " * 58 + "*" +print(borderMain) +print(borderMain) +print(borderMain) +print(borderMain) +print(borderMain) + +print(borderStars) + diff --git a/lecture20261020/strings04.py b/lecture20261020/strings04.py new file mode 100644 index 0000000..f859cbd --- /dev/null +++ b/lecture20261020/strings04.py @@ -0,0 +1,29 @@ + +data1 = "6" +data2 = 4 + + +print("The value of data1 is ",data1) +print("The value of data2 is ",data2) + + +print("The type of data1 is ",type(data1) ) +print("The type of data2 is ",type(data2) ) + +# Generates an error +#result = data1 + data2 + +# Works as long as data1 can be converted to an integer +result = int(data1) + data2 + +# Works as long as you want string concatenation +#result = data1 + str(data2) + +print(result) + +result = int(data1) + data2 + +# Works as long as you want string concatenation +result = data1 + str(data2) + +print(result)