DL Notebook
13 august 2024
“Algorithms and data” Add 2 numbers
Algorithms
1. Start
2. Take input as a,b
3. Calculate c = a + b
4. Display c as output
5. Stop
Pseudocode
1. Input -> a,b
2. Complete c = a+b
3. Print c
Program (python)
1. a = (input("A "))
2. b = (input("B"))
3. c= a+b
4. Print c
Sample of Python code snippet :
1. Program to add two numbers -
2. number1 = input("Enter a number")
3. number2 = input("Enter a number")
4. result = number1 + number2
5. print(result)
“Algorithms and data” Add 3 numbers
Algorithms
1. Start
2. Take input as a,b,c
3. Calculate d = a * b*c
4. Display d as output
5. Stop
Pseudocode
1. Input -> a,b,c
2. Complete d = a*b*c
3. Print c
Program (python)
1. a = (input("A "))
2. b = (input("B"))
3. c = (input("c"))
4. d= a*b*c
5. Print d
Day 2
Tuesday Aug 20 ,2024
# Pseudo Code to check if number is greater than 10
● Start
● Input a
● If a>10 print a
# Pseudo Code to check if a number is divisible by 3 or not.
Input -> a
If a ÷3 == 0 print (true)
Else print (false)
Division operations
/ -> division -> quotient including decimals
÷ -> modules -> remainder
// -> division -> excluding decimals
Day 3
Tuesday Sep 3 ,2024
# pseudocode to make a calculator for two values as per the users choice of operations
1. Input <- a,b
2. Input <- operator
3. If operator ==’+’ print (a+b)
4. Elif operator ==’-’ print (a-b)
5. Elif operator == ‘ * ’ print (a*b)
6. Dif operator == ‘/’ print (a/b)
7. else : print (invalid operator )
Iteration
#for loop
1. For i =1 to10
2. Print (1*2)
Day 4
Tuesday Sep 10 ,2024
Algorithms and Pseudo Codes Worksheet
Answer the following questions by making a pseudocode for the given tasks.
Ex-1 Write a pseudocode that calculates the sum of two numbers and
display the result.
1. Take input as a,b
2. Calculate c = a + b
3. Print c as output
Ex-2 Write a pseudocode that calculates the sum of powers of two numbers
A and B as shown by the formula below and display the result.
R = AB + BA
1. input A
2. Input B
3. Input sum
4. Compute "Enter the value of A: "
5. Input A
6. Compute "Enter the value of B: "
7. Input B
8. sum = A^2 + B^2
9. Print "The sum of the squares of", A, "and", B, "is", sum
Ex-3 Write a pseudocode that will display the numbers from 1 forward to 10.
1. For i =1 to10
2. Print (1*2)
Day 5
Tuesday Sep 17 ,2024
● Electronic circuits in computers, solid start drivers and controlling discs are
made up of thousands of logic gates.
● Logic gates combined together to form logic circuits.
● A truth table Lists every binary output for every
Day 6
Tuesday october 1st, 2024
Programing with python
Data types
Variables share different type of data
int (integer)
1,2,20,-3,-4
Flat(flat print numbers)
40,34,25,5.0
String
“Hello”
”abc”
“London”
“123”
Comparison operations
> Greater than a>b
>= Greater than or equal to a>=b
< less than a<b
<= less than or equal to a<=b
== equals to/equality a==b
!= not equal to a! =b
Calculator H.W
DISPLAY "Select an operation:"
DISPLAY "1. Add"
DISPLAY "2. Subtract"
DISPLAY "3. Multiply"
DISPLAY "4. Divide"
IF operation IN (1, 2, 3, 4) THEN
num1 = GET_USER_INPUT("Enter the first number:")
num2 = GET_USER_INPUT("Enter the second number:")
IF operation = 1 THEN
result = ADD(num1, num2)
DISPLAY "Result: " + result
ELSE IF operation = 2 THEN
result = SUBTRACT(num1, num2)
DISPLAY "Result: " + result
ELSE IF operation = 3 THEN
result = MULTIPLY(num1, num2)
DISPLAY "Result: " + result
ELSE IF operation = 4 THEN
IF num2 = 0 THEN
DISPLAY "Error: Division by zero is not allowed."
ELSE
END FUNCTION
Day 8
Tuesday November 5th, 2024
print(f"\nOutput:")
print(f"City: {city}")
print(f"AQI of {city} is {aqi_value}")
print(f"AQI is {aqi_category} in your city.")