Understanding the BCA Syllabus Avadh University – Semester I Paper BCA101 T Unit IV

Semester I BCA Syllabus BCA101 T – Programming Principles Using Python

Semester I Paper BCA101 T Unit IV – Strings and Lists

  1. Strings
    • String Class and Basics
    • Built-in String Functions
    • String Traversal and Operations
    • String Operators and Operations*
  2. Lists
    • List Creation and Basics
    • List Traversal and Operations
    • List Slicing and Splitting
    • Passing Lists to Functions*

String Class and Basics

  • Introduction to strings as a data type.
  • Creation and manipulation of strings.
  • String literals and escape sequences.
Creating and manipulating strings example

name = “John”
greeting = “Hello, ” + name + “!”
print(greeting)

Built-in String Functions

Exploring common string functions:

  • len(): Finding the length of a string.
  • upper(), lower(): Changing case.
  • isdigit(), isalpha(): Checking character types.
Using built-in string functions

text = “Python123”
print(len(text)) # Output: 9
print(text.upper()) # Output: PYTHON123
print(text.isdigit()) # Output: False

String Traversal and Operations

  • Traversing strings using loops (for, while).
  • String indexing and slicing.
  • Concatenation and string repetition.
String traversal and operations

sentence = “Python is fun!”
for char in sentence:
print(char)

print(sentence[0]) # Output: P
print(sentence[7:9]) # Output: is
print(sentence * 2) # Output: Python is fun!Python is fun!

String Operators and Operations*

  • Comparison operators for strings.
  • Logical operators and their use with strings.
  • String formatting using f-strings.
String operators and operations

text1 = “apple”
text2 = “banana”
print(text1 < text2) # Output: True (lexicographical comparison)
print(text1 == “apple”) # Output: True

name = “Alice”
age = 25
print(f”My name is {name} and I am {age} years old.”)

Lists:

List Creation and Basics

  • Introduction to lists as a data structure.
  • Creating lists and list literals.
  • Lists with mixed data types.
Creating lists

fruits = [“apple”, “banana”, “cherry”]mixed_list = [1, “apple”, True, 3.14]

List Traversal and Operations

  • Traversing lists using loops (for, while).
  • List indexing and slicing.
  • List concatenation and repetition.
List traversal and operations example

numbers = [1, 2, 3, 4, 5]for num in numbers:
print(num)

print(numbers[2]) # Output: 3
print(numbers[1:4]) # Output: [2, 3, 4]print(numbers * 2) # Output: [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]

List Slicing and Splitting

  • List slicing and modifying elements.
  • Splitting and joining lists.
List slicing and splitting example

colors = [“red”, “green”, “blue”, “yellow”]colors[1] = “purple” # Modifying an element
print(colors) # Output: [“red”, “purple”, “blue”, “yellow”]

text = “apple,banana,cherry”
fruits = text.split(“,”)
print(fruits) # Output: [“apple”, “banana”, “cherry”]

Passing Lists to Functions*

  • Passing lists as function arguments.
  • Modifying lists within functions.
Passing lists to functions example

def add_element(my_list, element):
my_list.append(element)

numbers = [1, 2, 3]add_element(numbers, 4)
print(numbers) # Output: [1, 2, 3, 4]

The above-mentioned explanation illustrates Python programming with a focus on strings and lists. Students are encouraged to practice regularly and seek additional resources to deepen their understanding of Python programming.

Leave a Comment