English Grammar - The Complete Guide.

English Grammar Complete Guide

Learning English grammar can seem like a daunting task, but with a structured approach, it becomes a more manageable and rewarding journey. Whether you're a beginner or someone looking to brush up on your grammar skills, here's a comprehensive guide on how to start learning English grammar, where to begin, and the essential topics to cover in a logical sequence.


Start with the Basics of English Grammar.

Begin by understanding the fundamental building blocks of English grammar. This foundation will provide you with a solid understanding of the structure of sentences. Below are the basic Grammar topics that you cover in this section.


Parts of Speech.

  • Verbs
  • Adjectives
  • Adverbs
  • Pronouns
  • Prepositions
  • Conjunctions
  • Interjections

Sentence Structure.

Once you cover the basics of English Grammar you should explore the structure of sentences and how words come together to convey meaning. Understand subjects, predicates, objects, and how to create clear and grammatically correct sentences. This knowledge is crucial for effective communication in both spoken and written English. Below are the topics you can cover in this section.

  • Subjects and Predicates
  • Sentence Types (Declarative, Interrogative, Imperative, Exclamatory)
  • Sentence Fragments and Run-On Sentences
  • Combining Sentences (Coordination and Subordination)


Tenses.

Tenses play a vital role in expressing the timing of actions. Learn about the different tenses in English, such as past, present, and future, including their various forms and when to use them appropriately. Below are the types of tenses you should cover in this section.

  • Simple Present Tense
  • Present Continuous Tense
  • Present Perfect Tense
  • Present Perfect Continuous Tense
  • Simple Past Tense
  • Past Continuous Tense
  • Past Perfect Tense
  • Past Perfect Continuous Tense
  • Simple Future Tense
  • Future Continuous Tense
  • Future Perfect Tense
  • Future Perfect Continuous Tense
  • Perfect vs. Progressive Tenses

Grammar Rules and Exceptions.

Familiarize yourself with common grammar rules, such as subject-verb agreement, proper word order, and punctuation. Be aware of exceptions and irregularities, as they often add nuance to the language.

  • Subject-Verb Agreement
  • Word Order
  • Punctuation (Commas, Periods, Apostrophes, Colons, Semicolons)
  • Capitalization

Expand Vocabulary.

Build your vocabulary in English to express ideas more precisely. Learn synonyms, antonyms, and idiomatic expressions. A rich vocabulary enhances both written and spoken communication.
  • Synonyms and Antonyms
  • Idiomatic Expressions
  • Word Roots and Affixes
  • Contextual Vocabulary Building

Remember, learning English grammar is a gradual process, and consistency is key. Break down the vast subject into manageable segments, practice regularly, and celebrate your progress along the way.

Python Program to Find HCF (GCD).

In this tutorial, we will learn how to find HCF (Highest Common Factor) using Python Programming. But before moving to the topic let's understand briefly about HCF / GCD.

Python Program to Find HCF (GCD) of Two Numbers


HCF (Highest Common Factor).

The Highest Common Factor (HCF) is also known as the Greatest Common Divisor (GCD). It represents the largest positive integer that divides each of the numbers without leaving a remainder.


The Euclidean Algorithm is an ancient and efficient method for finding the Highest Common Factor (HCF) or Greatest Common Divisor (GCD) of two numbers. The algorithm is based on the fact that the HCF of two numbers remains the same even if the larger number is replaced by the remainder when divided by the smaller number.


Example: Find HCF of 48 and 18.

Solution:
1. Take-Two Numbers:
a = 48, b = 18

2. Divide the Larger Number by the Smaller Number:
a/b = 48/18 = 2 with a remainder of r=12.

3. Replace Larger Number with Smaller Number and Remainder:
Replace a with b and b with r so, a = 18, b = 12

4. Repeat the process:
a/b = 18/12 = 1 with a remainder of r = 6.

5. Replace again:
Replace a with b and b with r so, a = 12, b = 6

6. Continue Until Remainder is Zero:
Repeat the process until the remainder becomes zero. 
a/b = 12/6 = 2 with a remainder of r = 0.

7. The Last Non-Zero Remainder is the HCF:
The last non-zero remainder is the HCF.
The last non-zero remainder is 6, so HCF of 48 and 18 is 6.

Python Code for Finding HCF.

Here's a Python program that uses the Euclidean Algorithm to find the HCF of two numbers:
# Python code to find HCF of two numbers
def find_hcf(a, b):
    while b:
        a, b = b, a % b
    return a

# Example usage:
num1 = 64
num2 = 22
hcf_result = find_hcf(num1, num2)
print(f"The HCF of {num1} and {num2} is {hcf_result}")
Output:
The HCF of 64 and 22 is 2

Explanation:

In the above example, the find_hcf function takes two numbers, a and b, as parameters. It uses a while loop to repeatedly set a to the value of b, and b to the remainder when a is divided by b. This process continues until b becomes zero, and the last non-zero remainder is the HCF.

Python Program to Find LCM.

In Python Programming there are multiple methods to find the LCM (Least Common Factor) of two numbers. In this article, we will discuss all those methods in detail with explanation and example code. But before moving to those methods let's get a brief introduction about LCM. 

Find LCM of Two Numbers in Python

LCM (Least Common Factor). 

The Least Common Multiple (LCM) is the smallest positive integer that is divisible by each of the given integers. In simpler terms, it's the smallest number that both numbers divide into evenly.

Let's understand with an example: Find LCM of 4 and 5. 
  • Multiple of 4 are: 4, 8, 12, 16, 20, 24, ...
  • Multiple of 5 are: 5, 10, 15, 20, 25, 30, ...
The smallest number that appears in both lists is 20. Therefore, the LCM of 4 and 5 is 20.

This is one of the methods of finding the LCM of two numbers similarly there are many and we will learn all of them now with Python code.

Method 1: Find LCM Using Loop.

This approach involves finding the LCM through an iterative process using a loop. It starts with the larger of the two numbers and increments until a common multiple is found.

Algorithm:

  • Initialize a variable (greater) with the maximum of the two numbers.
  • Use a while loop to iterate until a common multiple is found.
  • Check if both numbers are divisible by the current value of greater.
  • If yes, the current value of greater is the LCM.

Python Code:
# Function to find LCM of two numbers
def find_lcm(a, b):
    greater = max(a, b)
    while True:
        if greater % a == 0 and greater % b == 0:
            lcm = greater
            break
        greater += 1
    return lcm

num1 = 4
num2 = 5
result = find_lcm(num1, num2)
print(f"The LCM of {num1} and {num2} is {result}")
Output:
The LCM of 4 and 5 is 20

Method 2: Find LCM Using GCD (Greatest Common Factor).

This approach utilizes the relationship between LCM and GCD. The formula is LCM(a, b) = |a * b| / GCD(a, b).

Algorithm:

  • Import the math module of Python.
  • Use the math.gcd() function to find the GCD of the two numbers.
  • Calculate LCM using the above formula.

Python Code:

# Python code to find LCM of two numbers
import math

def find_lcm(a, b):
    return abs(a * b) // math.gcd(a, b)

# Numbers to find LCM
num1 = 12
num2 = 13
result = find_lcm(num1, num2)
print(f"The LCM of {num1} and {num2} is {result}")
Output:
The LCM of 12 and 13 is 156

Method 3: Find LCM Using Prime Factors.

This approach leverages the prime factorization of numbers. The LCM is found by combining the prime factors of both numbers with the maximum occurrence.

Algorithm:

  • Define a helper function to find prime factors.
  • Use Counter to get the occurrence of prime factors for each number.
  • Combine the prime factors with the maximum occurrence.
  • Calculate LCM using the product of prime factors.

Python Code:

# Python code to find LCM using Prime Factors
from collections import Counter

def find_lcm(a, b):
    def prime_factors(n):
        i = 2
        factors = []
        while i * i <= n:
            if n % i:
                i += 1
            else:
                n //= i
                factors.append(i)
        if n > 1:
            factors.append(n)
        return factors

    factors_a = Counter(prime_factors(a))
    factors_b = Counter(prime_factors(b))

    # Combine prime factors with maximum occurrence
    all_factors = factors_a | factors_b

    # Calculate LCM using prime factors
    lcm = 1
    for factor, count in all_factors.items():
        lcm *= factor ** count

    return lcm

# Example usage:
num1 = 5
num2 = 6
result = find_lcm(num1, num2)
print(f"The LCM of {num1} and {num2} is {result}")
Output:
The LCM of 5 and 6 is 30

These are the three different ways of finding the LCM of two numbers, you can use any one of them based on your understanding and requirement to solve coding problems in Python.

Python Program to Display the Multiplication Table.

Multiplication tables are fundamental in mathematics and are often required in various applications. In this article, we'll explore how to write a Python program to display the multiplication table for a given number.


Steps to Print Multiplication Table in Python.

We can print a multiplication table of any number (from 1 to 10) in Python using a loop and in our example, we are going to use for loop.


Below are the steps to follow:

  • Accept a number from the user for which you want to print the table.
  • Use a loop to iterate from 1 to the desired range (example: 1 to 10).
  • Multiply the input number by the current iteration variable in each step.
  • Display the result in the desired format of a multiplication table.  

Python Code:

# Python Program to Display the Multiplication Table

# Step 1: Accept a number from the user
number = int(input("Enter the number: "))

# Step 2: Display the multiplication table up to 10
print(f"Multiplication Table for {number}:")
for i in range(1, 11):
    result = number * i
    print(f"{number} x {i} = {result}")
Output:
Enter the number: 12
Multiplication Table for 12:
12 x 1 = 12
12 x 2 = 24
12 x 3 = 36
12 x 4 = 48
12 x 5 = 60
12 x 6 = 72
12 x 7 = 84
12 x 8 = 96
12 x 9 = 108
12 x 10 = 120

Explanation:

In the above example, we use the input() function to get a number from the user. The for loop runs from 1 to 10 (inclusive) to generate the multiplication table. Inside the loop, we multiply the user-entered number by the current loop variable (i) to calculate the result. The print() statement displays the multiplication table in the required format.

Python Program to Convert Celsius to Fahrenheit and Visa Versa.

Temperature often needs to be converted between different scales. In this article, we'll explore how to convert Celsius to Fahrenheit and Fahrenheit to Celsius using Python.  

Convert Celsius to Fahrenheit and Visa Versa in Python

Celsius and Fahrenheit are two different measuring units to use to measure temperature. Celsius unit is widely used around the world, especially in scientific contexts where Fahrenheit is primarily used in the United States, its territories and associated states, and the Bahamas.


The formula to convert Celsius (C) to Fahrenheit (F) is given by:

  • F = C x 9/5 + 32

The formula to convert Fahrenheit (F) to Celsius (C) is given by:

  • C = 5/9 x (F - 32)

Python Program to Convert Celsius to Fahrenheit. 

In this Python program, we are going to take the value of Celsius from the user and then we will use the formula F = (C * 9/5) + 32 to calculate the value of Fahrenheit. 

Python Code:

# Temperature in celsius degree
celsius = float(input("Enter temperature in Celsius: "))
 
# Converting the celsius to
# fehrenheit using the formula
fahrenheit = (celsius * 9/5) + 32
 
# printing the result
print('%.2f Celsius is equivalent to: %.2f Fahrenheit'% (celsius, fahrenheit))
Output:
Enter temperature in Celsius: 100
100.00 Celsius is equivalent to: 212.00 Fahrenheit

Python Program to Convert Fahrenheit to Celsius.

Here in this Python program, we are going to take the value of Fahrenheit as input from the user. We will then use the formula C = 5/9 * (F - 32) to convert the temperature of Fahrenheit to Celsius.

Python Code:
# Temperature in Fahrenheit degree
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
 
# Converting the Fahrenheit to
# Celsius using the formula
celsius = 5/9 * (fahrenheit - 32)
 
# printing the result
print('%.2f Fahrenheit is equivalent to: %.2f Celsius'% (fahrenheit, celsius))
Output:
Enter temperature in Fahrenheit: 212
212.00 Fahrenheit is equivalent to: 100.00 Celsius

So these are the two Python codes to convert temperature from Fahrenheit to Celsius and Celsius to Fahrenheit. 

Python Program to Convert Kilometers to Miles.

In this tutorial, will learn how to convert Kilometers to Miles using Python Programming. We'll cover the algorithm, provide a step-by-step guide, and offer Python code with explanations.

Understanding the Conversion.

The conversion from kilometers to miles involves a simple mathematical formula. The relationship between kilometers (K) and miles (M) is given by:

Formula: Miles = Kilometers × 0.621371

This formula states that one kilometer is approximately equal to 0.621371 miles.

Algorithm to Convert Kilometers to Miles.

Step 1: Take the value of kilometers as input from the user.
Step 2: Use the formula M = Km x 0.621371 to calculate Miles and store the result in a variable.
Step 3: Print the value stored in the variable as output. 

Python Code:
# Python program to convert kilometers to miles
distance_in_km = float(input("Enter distance in kilometers: "))

conversion_factor = 0.621371
# Calculating miles
distance_miles = distance_in_km * conversion_factor

# Displaying the result
print(f"{distance_in_km} kilometers is equal to {distance_miles:.2f} miles.")
Output:
Enter distance in kilometers: 12
12.0 kilometers is equal to 7.46 miles.

This Python program provides a straightforward way to convert distances from kilometers to miles. Understanding such conversions is crucial in various applications, including travel, fitness tracking, and geographic calculations.

ord() and chr() Function in Python.

In Python, the ord() and chr() functions are essential tools for working with Unicode, they allow you to convert an integer to Unicode and Unicode to an integer respectively. Let's dive deeper into these functions.


What is Unicode?

Unicode is a standardized character encoding system that assigns a unique number, known as a code point, to every character in almost every script and language in the world. It is designed to be a universal character set, encompassing characters from different writing systems. For example, 'A' is assigned the code point 65, and '❤' is assigned the code point 2764.


What is ord() in Python?

The ord() function in Python is a built-in function that returns an integer representing the Unicode character. It stands for "ordinal," and its primary use is to obtain the Unicode code point of a given character.

Syntax:

ord(character)

Python Code:
# Using ord() to get the Unicode code point of a character

unicode_value = ord('A')

print(f"The Unicode code point of 'A' is {unicode_value}")
Output:
The Unicode code point of 'A' is 65

In this example, ord('A') returns 65, which is the Unicode code point for the character 'A'.

What is chr() in Python?

In Python, chr() is a built-in function that converts an integer representing a Unicode code point into the corresponding character. The name chr stands for "character." This function is the inverse of the ord() function, which converts a character to its Unicode code point.

Syntax: 
# i is an integer representing an integer point
chr(i)

Python Code:
# Using chr() to convert a Unicode code point to a character
unicode_code_point = 65  # Unicode code point for 'A'
character = chr(unicode_code_point)

# Printing the result
print(f"The character to the Unicode code point {unicode_code_point} is: {character}")

In this example, chr(65) returns the character 'A' because 65 is the Unicode code point for the uppercase letter 'A.'

In this article, we have discussed ord() and chr() functions which help us in working with Unicode. It is an important concept to learn for solving many real-life coding problems.

Python Program To Find ASCII Value of a character.

Finding the ASCII value of a character in Python programming is useful for solving many coding problems. In this tutorial, we will learn different ways to find the ASCII  value of any given character.

What is ASCII Value?

ASCII, which stands for American Standard Code for Information Interchange, is a character encoding standard used for representing text and control characters in computers and other devices that use text.

In ASCII, each character is assigned a unique numeric value. The standard ASCII set uses values ranging from 0 to 127, representing basic characters such as letters, digits, punctuation, and control characters.

Example:
  • The ASCII value for the uppercase letter 'A' is 65.
  • The ASCII value for the lowercase letter 'a' is 97.
  • The ASCII value for the digit '0' is 48.
  • The ASCII value for the exclamation mark '!' is 33.

Python Code to Find ASCII Value of a Character.

In Python, the ord() function can be used to find the ASCII value of a character.

Here's a simple Python program to get ASCII value:
character = input("Enter a character: ")

# ASCII value of character
ascii_value = ord(char)
print(f"The ASCII value of {character} is {ascii_value}")
Output:
Enter a character: D
The ASCII value of D is 68

The ord() function in Python is a built-in function that returns an integer representing the Unicode character. 

Python Program to Find Character from ASCII Value.

The chr() function is the inverse of ord(). It converts an ASCII value to its corresponding character. 

Here is a simple Python Code to get a Character from an ASCII value:
ascii_value = int(input("Enter an ASCII value: "))

character = chr(ascii_value)

print(f"The character for ASCII value {ascii_value} is {character}")
Output:
Enter an ASCII value: 65
The character for ASCII value 65 is A

These approaches showcase the simplicity and flexibility of Python when working with ASCII values. 


Related post:

DON'T MISS

Tech News
© all rights reserved
made with by AlgoLesson