IDUL JOHA

Data Science


Data Science is a field of study that combines statistics, machine learning, and artificial intelligence to extract knowledge and insights from data. It is a rapidly growing field with a wide range of applications in various industries, including healthcare, finance, retail, and more. Data scientists use a variety of tools and techniques to analyze data, identify patterns, and make predictions. They work with large datasets and use advanced algorithms to solve complex problems. Data science is a highly interdisciplinary field that requires a strong foundation in mathematics, statistics, and computer science. It is a rapidly growing field with a wide range of applications in various industries, including healthcare, finance, retail, and more. Data scientists use a variety of tools and techniques to analyze data, identify patterns, and make predictions. They work with large datasets and use advanced algorithms to solve complex problems. Data science is a highly interdisciplinary field that requires a strong foundation in mathematics, statistics, and computer science.


Basic Python


Python is a general-purpose programming language. It is used in web development, machine learning, data analysis, and scientific computing. Python is a high-level, interpreted, and object-oriented programming language. Python is a dynamically typed language, which means that the type of a variable is determined at runtime. Python is a very popular language, and it is used by many companies, including Google, Facebook, and Amazon. Python is a very powerful language, and it is used by many developers. Python is a very popular language, and it is used by many companies, including Google, Facebook, and Amazon. Python is a very powerful language, and it is used by many developers. Python is a very popular language, and it is used by many companies, including Google, Facebook, and Amazon. Python is a very powerful language, and it is used by many developers. Python is a very popular language, and it is used by many companies, including Google, Facebook, and Amazon. Python is a very powerful language, and it is used by many developers. Python is a very popular language, and it is used by many companies, including Google, Facebook, and Amazon. Python is a very powerful language, and it is used by many developers. Python is a very popular language, and it is used by many companies, including Google, Facebook, and Amazon. Python is a very powerful language, and it is used by many developers. Python is a very popular language, and it


Python Data Types


  1. Numeric Types
  2. Sequence Types
  3. Mapping Types
  4. Boolean Type
  5. None Type

Numeric Types

                    
                        int: Integer type for whole numbers.
                        python
                        Copy code
                        a = 10
                        float: Floating-point type for decimal numbers.
                        python
                        Copy code
                        b = 10.5
                        complex: Complex numbers with real and imaginary parts.
                        python
                        Copy code
                        c = 1 + 2j
                
                

Sequence Types

                    
                        str: String type for text. 
                        python
                        Copy code
                        s = "Hello, World!"
                        list: Ordered, mutable collection of items.
                        python
                        Copy code
                        list = [1, 2, 3, 4, 5]
                        tuple: Ordered, immutable collection of items.
                        python
                        Copy code
                        tpl = (1, 2, 3, 4, 5)
                    
                

Mapping Types

                    
                        dict: Collection of key-value pairs.
                        python
                        Copy code
                        d = {"name": "Alice", "age": 30}
                    
                

Boolean Type

                        
                            bool: Boolean type with two possible values: True and False.
                            python
                            Copy code
                            is_active = True
                            bool: True or False.
                        
                    

Non-Primitive Types

                        
                            class: User
                            python
                            NoneType: Special type with a single value None used to signify 'nothing' or 'no value'.
                            python
                            Copy code
                            x = None
                        
                    

Example

                        
                            # Numeric Types
                            a = 10        # int
                            b = 10.5      # float
                            c = 1 + 2j    # complex

                            print(type(a))  # 
                            print(type(b))  # 
                            print(type(c))  # 

                            # Sequence Types
                            s = "Hello, World!"  # str
                            st = [1, 2, 3, 4, 5]  # list
                            tpl = (1, 2, 3, 4, 5)  # tuple

                           print(type(s))   # 
                           print(type(lst)) # 
                           print(type(tpl)) # 

                            # Set Types
                            st = {1, 2, 3, 4, 5}  # set
                            fs = frozenset([1, 2, 3, 4, 5])  # frozenset

                               print(type(st))  # 
                               print(type(fs))  # 

                             # Mapping Type
                             d = {"name": "Alice", "age": 30}  # dict

                            print(type(d))  # 

                             # Boolean Type
                             is_active = True

                            print(type(is_active))  # 

                             # None Type
                             x = None

                            print(type(x))  # 

                        
                    

ATM SYSTEM


This is a simple ATM system that allows users to perform basic banking operations such as depositing and withdrawing money, checking their account balance, and transferring funds to other accounts. The system is designed to be user-friendly and intuitive, with a simple interface that makes it easy for users to navigate and perform transactions.

                
                    // ATM SYSTEM  FIRST 

                    def Atm_system():
    balance=452135
    Currect_pin=1234

    print('Welcome to ATM')
    pin=int(input('Enter your pin:'))
    if pin!=Currect_pin:
      print('Incurrect pin')
      return

    while True:
        print('''Option you can exercies are
          1) balance
          2) withdrawl
          3) Deposit
          4) exit
          ''')
        option=int(input('Enter your option:'))
        if option==1:
            print(f'Your balance is:{balance}')
        elif option==2:
            withdrawl=int(input('enter amaount'))
            if withdrawl<=balance:
                balance-=withdrawl
                print('withdrawl is successfull')
                print(f'Your balance is :{balance}')
            else:
                print('insufficient balance')
        elif option==3:
            deposit=int(input('enter amount'))
            balance+=deposit
            print('deposit is successfull')
            print(f'Your balance is :{balance}')

        elif option==4:
            print('Thank you')
            break
        else:
            print('Incurrect option')
Atm_system()


// ATM SYSTEM SECONDS WAYS

def atm_simulation():
    balance = 34510
    correct_pin = 1234
    attempts = 0
    max_attempts = 3

    print('Welcome to the ATM')

    while attempts < max_attempts:
        try:
            pin = int(input('Enter your PIN: '))
            if pin != correct_pin:
                attempts += 1
                if attempts < max_attempts:
                    print(f'Incorrect PIN. You have {max_attempts - attempts} attempts left. Try again.')
                else:
                    print('Incorrect PIN. No attempts left. Exiting.')
                    return
            else:
                break
        except ValueError:
            print('Invalid input. Please enter a numeric PIN.')

    while True:
        print('''
Options you can exercise are:
1) Check Balance
2) Withdraw
3) Deposit
4) Exit
''')
        try:
            option = int(input('Enter your option: '))
            if option == 1:
                print(f'Your balance is: {balance}')
            elif option == 2:
                try:
                    withdrawal = int(input('Enter amount to withdraw: '))
                    if withdrawal <= balance:
                        balance -= withdrawal
                        print('Withdrawal successful.')
                        print(f'Your new balance is: {balance}')
                    else:
                        print('Insufficient balance.')
                except ValueError:
                    print('Invalid input. Please enter a numeric amount.')
            elif option == 3:
                try:
                    deposit = int(input('Enter amount to deposit: '))
                    balance += deposit
                    print('Deposit successful.')
                    print(f'Your new balance is: {balance}')
                except ValueError:
                    print('Invalid input. Please enter a numeric amount.')
            elif option == 4:
                print('Thank you for using the ATM. Goodbye!')
                break
            else:
                print('Incorrect option. Please try again.')
        except ValueError:
            print('Invalid input. Please enter a numeric option.')

atm_simulation()
                
            

AGE CALUCATER SYSTEM


This is a simple age calculator that allows users to calculate their age based on their date of birth. The system is designed to be user-friendly and intuitive, with a simple interface that makes it easy for users to enter their date of birth and calculate their age.

                    
                        // firts code for calculate 
                        from datetime import datetime

                        def calculate_duration(dob, unit):
                            """
                            Calculate the duration of time a person has lived based on their DOB in a specified unit.
                        
                            :param dob: Date of Birth of the person (datetime object)
                            :param unit: Time unit for the calculation (Days, Hours, Minutes, Seconds)
                            :return: The calculated duration in the specified unit
                            """
                            now = datetime.now()
                            delta = now - dob
                        
                            if unit.lower() == 'years':
                                duration = delta.days / 365
                            elif unit.lower() == 'months':
                                duration = delta.days / 30
                            elif unit.lower() == 'weeks':
                                duration = delta.days / 7
                            elif unit.lower() == 'days':
                                duration = delta.days
                            elif unit.lower() == 'hours':
                                duration = delta.days * 24 + delta.seconds / 3600
                            elif unit.lower() == 'minutes':
                                duration = (delta.days * 24 * 60) + (delta.seconds / 60)
                            elif unit.lower() == 'seconds':
                                duration = (delta.days * 24 * 60 * 60) + delta.seconds
                            else:
                                raise ValueError("Invalid time unit selected")
                        
                            return duration
                        
                        def main():
                            """
                            Main function to interact with the user and calculate the duration of their age in the selected time unit.
                            """
                            while True:
                                dob_input = input("What's your date of birth? (format: YYYY-MM-DD) ")
                                try:
                                    dob = datetime.strptime(dob_input, "%Y-%m-%d")
                                    if dob > datetime.now():
                                        raise ValueError("Date of birth cannot be in the future")
                                    break
                                except ValueError as e:
                                    print(f"Invalid input: {e}. Please enter a valid date in the format YYYY-MM-DD.")
                        
                            while True:
                                print('''
                        Options you can exercise are:
                        1) years
                        2) Months
                        3) Weeks
                        4) Days
                        5) Hours
                        6) Minutes
                        7) Seconds
                        8) Exit
                        ''')
                                option = int(input('Enter your option: '))
                                if option == 1:
                                    duration = calculate_duration(dob, 'years')
                                    print(f'You have lived for {duration:.0f} years.')
                                elif option == 2:
                                    duration = calculate_duration(dob, 'months')
                                    print(f'You have lived for {duration:.0f} months.')
                                elif option == 3:
                                    duration = calculate_duration(dob, 'weeks')
                                    print(f'You have lived for {duration:.0f} weeks.')
                                elif option == 4:
                                    duration = calculate_duration(dob, 'days')
                                    print(f'You have lived for {duration:.0f} days.')
                                elif option == 5:
                                    duration = calculate_duration(dob, 'hours')
                                    print(f'You have lived for {duration:.0f} hours.')
                                elif option == 6:
                                    duration = calculate_duration(dob, 'minutes')
                                    print(f'You have lived for {duration:.0f} minutes.')
                                elif option == 7:
                                    duration = calculate_duration(dob, 'seconds')
                                    print(f'You have lived for {duration:.0f} seconds.')
                                elif option == 8:
                                    print('Thank you. Goodbye!')
                                    break
                                else:
                                    print('Invalid option selected. Please try again.')
                        
                        if __name__ == "__main__":
                            main()


                             // firts code for calculate  diffrent way

                             from datetime import datetime

def calculate_duration(dob):
    """
    Calculate the duration of time a person has lived based on their DOB in various units.

    :param dob: Date of Birth of the person (datetime object)
    :return: A dictionary with the calculated duration in various units
    """
    now = datetime.now()
    delta = now - dob

    durations = {
        'years': delta.days / 365.25,
        'months': delta.days / 30.44,
        'weeks': delta.days / 7,
        'days': delta.days,
        'hours': delta.days * 24 + delta.seconds / 3600,
        'minutes': (delta.days * 24 * 60) + (delta.seconds / 60),
        'seconds': (delta.days * 24 * 60 * 60) + delta.seconds
    }

    return durations

def main():
    """
    Main function to interact with the user and calculate the duration of their age in various time units.
    """
    while True:
        dob_input = input("What's your date of birth? (format: YYYY-MM-DD) ")
        try:
            dob = datetime.strptime(dob_input, "%Y-%m-%d")
            if dob > datetime.now():
                raise ValueError("Date of birth cannot be in the future")
            break
        except ValueError as e:
            print(f"Invalid input: {e}. Please enter a valid date in the format YYYY-MM-DD.")

    durations = calculate_duration(dob)

    print('''
Options you can exercise are:
1) All Units
2) Years
3) Months
4) Weeks
5) Days
6) Hours
7) Minutes
8) Seconds
9) Exit
''')
    while True:
        option = int(input('Enter your option: '))
        if option == 1:
            print(f'You have lived for:')
            print(f'{durations["years"]:.2f} years')
            print(f'{durations["months"]:.2f} months')
            print(f'{durations["weeks"]:.2f} weeks')
            print(f'{durations["days"]:.0f} days')
            print(f'{durations["hours"]:.0f} hours')
            print(f'{durations["minutes"]:.0f} minutes')
            print(f'{durations["seconds"]:.0f} seconds')
        elif option == 2:
            print(f'You have lived for {durations["years"]:.2f} years.')
        elif option == 3:
            print(f'You have lived for {durations["months"]:.2f} months.')
        elif option == 4:
            print(f'You have lived for {durations["weeks"]:.2f} weeks.')
        elif option == 5:
            print(f'You have lived for {durations["days"]:.0f} days.')
        elif option == 6:
            print(f'You have lived for {durations["hours"]:.0f} hours.')
        elif option == 7:
            print(f'You have lived for {durations["minutes"]:.0f} minutes.')
        elif option == 8:
            print(f'You have lived for {durations["seconds"]:.0f} seconds.')
        elif option == 9:
            print('Thank you. Goodbye!')
            break
        else:
            print('Invalid option selected. Please try again.')

if __name__ == "__main__":
    main()

                    
                

Assignment - Statistics


This is a simple statistics calculator that allows users to calculate the mean, median, mode, and standard deviation of a dataset. The system is designed to be user-friendly and intuitive, with a simple interface that makes it easy for users to enter their data and calculate statistics.

1. Mean Calculation

                            
                            def calculate_mean(data):
                            if not data:
                            return None
                            return sum(data) / len(data)
                            
                            # Example usage
                            data = [1, 2, 3, 4, 5]
                            mean = calculate_mean(data)
                            print(f"Mean: {mean}")
                            
                            
                            
                        

2. Median Calculation

                            
                                def calculate_median(data):
                                if not data:
                                    return None
                                sorted_data = sorted(data)
                                n = len(sorted_data)
                                mid = n // 2
                                if n % 2 == 0:
                                    return (sorted_data[mid - 1] + sorted_data[mid]) / 2
                                else:
                                    return sorted_data[mid]
                            
                            # Example usage
                            data = [1, 2, 3, 4, 5]
                            median = calculate_median(data)
                            print(f"Median: {median}")
                            
                            
                            
                            
                        

3. Mode Calculation

                            
                                from collections import Counter

                                def calculate_mode(data):
                                    if not data:
                                        return None
                                    count = Counter(data)
                                    max_count = max(count.values())
                                    mode = [k for k, v in count.items() if v == max_count]
                                    return mode
                                
                                # Example usage
                                data = [1, 2, 2, 3, 4, 4, 4]
                                mode = calculate_mode(data)
                                print(f"Mode: {mode}")
                                
                            
                            
                        

Statistics Calculator

                            
                                import math
                                from collections import Counter
                                
                                def calculate_mean(data):
                                    if not data:
                                        return None
                                    return sum(data) / len(data)
                                
                                def calculate_median(data):
                                    if not data:
                                        return None
                                    sorted_data = sorted(data)
                                    n = len(sorted_data)
                                    mid = n // 2
                                    if n % 2 == 0:
                                        return (sorted_data[mid - 1] + sorted_data[mid]) / 2
                                    else:
                                        return sorted_data[mid]
                                
                                def calculate_mode(data):
                                    if not data:
                                        return None
                                    count = Counter(data)
                                    max_count = max(count.values())
                                    mode = [k for k, v in count.items() if v == max_count]
                                    return mode
                                
                                def calculate_standard_deviation(data):
                                    if not data:
                                        return None
                                    mean = calculate_mean(data)
                                    variance = sum((x - mean) ** 2 for x in data) / len(data)
                                    return math.sqrt(variance)
                                
                                # Example usage
                                data = [1, 2, 2, 3, 4, 4, 4, 5]
                                mean = calculate_mean(data)
                                median = calculate_median(data)
                                mode = calculate_mode(data)
                                std_dev = calculate_standard_deviation(data)
                                
                                print(f"Mean: {mean}")
                                print(f"Median: {median}")
                                print(f"Mode: {mode}")
                                print(f"Standard Deviation: {std_dev}")