Skip to content

Commit 81a6cca

Browse files
authored
Add files via upload
1 parent 885c794 commit 81a6cca

22 files changed

+422
-0
lines changed

ArithmeticOperations.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
print(1+1) #Addition
2+
print(3-1) #Subtraction
3+
print(2*1) #Multiplication
4+
print(2/1) #Division
5+
print(2//1) #Division,interger
6+
print(2**1) #Power
7+
print(2%1) #Modulus
8+
9+
#Argumented Assign Operator
10+
x = 10
11+
x -= 3
12+
x += 3
13+
print(x)
14+
15+
#OperatorPrecedence
16+
x = 10 + 3 * 2
17+
print(x)
18+
x = (2 + 3) * 10 - 3
19+
print(x)
20+
21+
#MathFunctions
22+
x = 2.9
23+
print(abs(-2.9))
24+
print(round(x))
25+
import math
26+
print(math.floor(x))

Collections.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#Collection
2+
#List
3+
#Set
4+
#Tuple
5+
6+
fruits = ["apple", "orange", "banana", "coconut"]
7+
#print(fruits[::])
8+
#for x in fruits:
9+
# print(x)
10+
print(help (fruits))

ComparisonOperators.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
temperature = 30
2+
3+
if temperature == 30:
4+
print("It's a hot day")
5+
else:
6+
print("It's not a hot day")
7+
8+
#EXERCISE
9+
number_of_characters = 3
10+
11+
if number_of_characters < 3:
12+
print("Name must atleast be 3 characters")
13+
if number_of_characters > 50:
14+
print("Name can be a maximum of 50 characters")
15+
else:
16+
print("Name looks good!")
17+
18+
#RECAP
19+
name = "TRUST"
20+
21+
if len(name) < 3:
22+
print("Name must atleast be 3 characters")
23+
elif len(name) > 50:
24+
print("Name can be a maximum of 50 characters")
25+
else:
26+
print("Name looks good!")

FormattedStrings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
first = 'John'
2+
last = 'Smith'
3+
message = first +'[' + last + '] is a coder'
4+
msg = f'{first} [{last}] is a coder'
5+
print(msg)
6+
print(10878-253-3350-7430)

GettingInput.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name = input('What is your name? ')
2+
print('Hi ' + name)
3+
4+
#EXERCISE
5+
name = input('What is your name?' )
6+
color = input('What is your favorite color? ')
7+
print( name + ' likes ' + color + '.')

HelloWorld.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
print("Hello Trust The Process")
2+
print("0----")
3+
print(" ||||")
4+
print("*" * 10)

IfStatements.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#pcc simple example
2+
cars = ['audi','bmw','subaru','toyota']
3+
for car in cars:
4+
if car == 'bmw':
5+
print(car.upper())
6+
else:
7+
print(car.title())
8+
print()
9+
cities = ['cities','lusaka','harare','lilongwe',]
10+
for city in cities:
11+
if city == 'cities':
12+
print(city.upper())
13+
else:
14+
print(city.title())
15+
print()
16+
17+
#Conditional Tests
18+
#Checking For Inequality
19+
requested_topping = 'mushrooms'
20+
if requested_topping != 'anchovies':
21+
print("Hold the anchovies!")
22+
#Numerical Camparisons
23+
answer = 17
24+
if answer != 42:
25+
print("That is not the correct answer. Please try again!")
26+
age = 19
27+
if age != 21:
28+
print("True")
29+
#Checking Multiple Conditions
30+
age_0 = 19
31+
if age_0 != 22:
32+
print("True")
33+
if age_0 <= 21:
34+
print("True")
35+
if age_0 >= 21:
36+
print("True")
37+
#IfStatement(CodeBasics)
38+
num = input("Enter a Number:")
39+
num = int(num)
40+
if num%2==0:
41+
print("Number is even")
42+
else:
43+
print("Number is odd")
44+
45+

LogicalOperators.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
has_high_income = True
2+
has_good_credit = False
3+
4+
if has_high_income or has_good_credit:
5+
print("Eligibe for loan")
6+
if has_high_income and not has_good_credit:
7+
print("Eligible for loan")

PROJECTWeightConverter.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
weight = int(input('Weight: '))
2+
unit = input('(L)bs or (K)g: ')
3+
if unit.upper() == "L":
4+
converted = weight * 0.45
5+
print(f"You are {converted} kilos.")
6+
else:
7+
converted = weight / 0.45
8+
print(f"You are {converted} pounds.")
9+
10+
11+
#Further_Thought
12+
currency = int(input('Currency: '))
13+
unit = input('(ZMW)K or (USD)$: ')
14+
if unit.upper() == "K100":
15+
forex = currency * 0.0387
16+
print(f"You are receiving {forex} dollars.")
17+
else:
18+
forex = currency / 0.0387
19+
print(f"You are receiving {forex} kwacha")

Parameters.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#PARAMETERS
2+
def greet_user(first_name, last_name):
3+
print(f'Hi {first_name}{last_name}!')
4+
print('Welcome aboard')
5+
6+
7+
print("Start")
8+
greet_user("John"," Smith")
9+
greet_user("Mary"," Johnsone")
10+
print("Finish")

0 commit comments

Comments
 (0)