Strings in Python

What is String in python?
  • In Python, String is a sequence of characters enclosed by either single quotes or double-quotes.
    • Example: 'Python', "Geek4Tutorial"
  • Strings are immutable.
  • Each value in a string is called character. 
Creating a String:
  • Strings can be created by enclosing the sequence of characters inside a single quote or double quote and assigning it to a variable.
Strings in Python
  • Sometimes triple quotes can also be used to create a string, even though triple quotes are used to represent Multiline strings and Docstrings.
Strings in Python
  • We can access the characters(element) in the string just like the index using index position.

Example python programs: Functions basics

Simple python programs to practice:

1) Write a Python function Factorial(n) which returns the factorial of the given number(n).

2) Write a Python function, Square(num) which returns the square of the given number(num).

3) Write a Python function, Sum(n) which returns the sum of first n numbers.

4) Write a Python function, Palindrome(num) that accepts an integer num as input and returns true/false based on condition.

    Ex: num = 12321 ---> output = 12321 ----> then given number is palindrome.

5) Write a Python function, check_strong_number(num) that accepts a positive as input, and returns true/false based on condition.
  • A number is said to be a Strong number if the sum of the factorial of each digit is equal to the given number.
   Ex: 145 is strong number as (1! =1) + (4! = 24) + (5! = 120) = 145.

Lists in Python

What is a List?
  • The list is one of the most common collection datatypes in Python which is ordered and mutable (changeable).
  • It is used to store a group of an element together in a sequence.
  • A list can store both homogenous and heterogeneous elements i.e., a single list may contain data types like integers, floats, strings as well as objects.
    • Individual value in a list is called an element.
    • These elements will be stored in a contiguous memory location.
      • For Ex:
        • Number1 = 10
        • Number2 = 20
        • Number3 = 30
        • Number4 = 40 
    • These individual variables can be represented in a list as
      • Number_list = [ 10, 20, 30, 40 ]

    Functions in Python basics

    Functions In python:
    • Set of instructions to perform a specific task.
    • Below is the syntax of functions in python:
                       def function_name([arg1,....,arg n]):
                              statement 1
                              ........
                              statement n
                              [return value]
                       variable = function_name([value1,......,value n])

    Control Structures

    • In general, Control structures decide the flow of the program execution.
    • The most commonly used control structures in python are
        • Sequential: control flows through all the statements, in the order of how the code is written.
        • Selection: Depends on the condition, control flows to the different statements.
        • Iteration: Certain blocks of code(statements) will be executed repeatedly.

      Basics of Python

      Code4tutorial basics of python
      • Python was created by Guido van Rossum in 1991 as a general-purpose programming language.
      • It is interpreted and interactive language. 
      • Python is an open-source language under a general public license (GPL). 
      • It supports both object-oriented and structured styles of programming.

      About: Introduction to Python Course

      Geek4Tutorial - Python Course
      Introduction to Python:
       
      This course is to introduce the basics of the Python programming language.
       
      About Python:
      • Python was created by Guido van Rossum in 1991 as a general-purpose programming language. It is interpreted and interactive language.
      • Python is an open-source language under a general public license (GPL). 
      • It supports both object-oriented and structured styles of programming.

      Python Operators

      • Operators are special symbols that are used to perform operations on the variables and the values.
      • Consider an expression 10 + 20 = 30. Here, + is an operator that performs addition. 10 and 20 are called operands and 30 is the output of the operation.
      • In general, the operand is a variable or a value that the operator operates on.
      • The most commonly used operator groups in python language are listed below
          • Arithmetic Operators
          • Comparison/Relational Operators
          • Logical Operators
          • Assignment Operators
          • Bitwise Operators
          • Identity Operators
          • Membership Operators
      • Let's have a look at each operator with their syntax.

      TANCET 2019 M.E./M.TECH Question paper & Solutions

       Tamil Nadu Common Entrance Test (TANCET ) is conducted by Anna University, Chennai on behalf of the Government of Tamil Nadu for the candidates who seek admission to  M.B.A.,  M.C.A., and M.E. / M.Tech. / M.Arch. / M.Plan. Degree Programs in Tamil Nadu.

      Previous year exam paper may help the candidates who have applied for the entrance examination of  TANCET. From this page, Candidates can download the previous year paper for their preparations from the below-given links.

      For loop - Python programs

      Display sum of 1 to 10 number by using for loop
       
      Code Snippet:


      While loop - Python program

      Find first n numbers divisible by 5 using while loop
       
      Code Snippet:

      Python Program - Arithmetic Operations

      Arithmetic Operations

      Code Snippet:

      Python program to read a list of integers and print only the multiples of 8

      Read a list of integers and print only the multiples of 8

      Code Snippet:

      Python program to find first 10 prime numbers

      First 10 prime numbers 

      Code Snippet:

      Python program to Create a list of the first 15 even numbers that are not divisible by 6

      Create a list of first 15 even numbers that are not divisible by 6 using for loop
       
      Code Snippet:
       

      Python program to find the greater of 2 numbers

      Write a function in python to find the greater of 2 numbers.

      Code Snippet:

      AS400 Control Language (CL) Interview questions

      In this blog post, we will see what are the major CL commands used in IBM iSeries/AS400. And what are the CL command questions asked during an interview? Let's see one by one below.

      You might also like

      Deploy your Django web app to Azure Web App using App Service - F1 free plan

      In this post, we will look at how we can deploy our Django app using the Microsoft Azure app service - a free plan. You need an Azure accoun...