Sanjana - Python--(presentation) comp. science .pptx

SanjanaSharma582210 36 views 21 slides May 17, 2024
Slide 1
Slide 1 of 21
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21

About This Presentation

PYTHON Presentation in computer Science


Slide Content

Presentation on Python By: Name – Sanjana Roll No.- 08 Class – B.ED (1 st ) PAGE 1

We will cover these topics PAGE 2 STRING AND ITS REPRESENTATION & TYPES

PAGE 3 PYTHON Python is a high-level, interpreted , general-purpose dynamic programming language focusing on code readability. The syntax in Python helps the programmers to do coding in fewer steps as compared to Java or C++.

APPLICATION OF PYTHON PAGE 4

What is String? Sequence of letters enclosed in quotes is called string. Strings in Python are surrounded by either single quotation marks or double quotation marks. ‘ Hello' is the same as “Hello". You can display a string literal with the print() function: For eg :- print("Hello") print('Hello') PAGE 5

REPRESENTATION OF STRING PAGE 6 Forward Indexing Backward Indexing >>> s = “Hello Python” This is how Python would index the string:

REPRESENTATION OF STRING PAGE 7 To access the first character on the string you just created, type and enter the variable name s and the index 0 within square brackets like this: >>>s[0] You’ll get this output: ‘H’

REPRESENTATION OF STRING PAGE 8 To access the last character, you can use this expression: >>>s[ len (s)-1] You’ll get the output: ‘n’ Len() function is used to find the length of the string.

REPRESENTATION OF STRING PAGE 9 The expression introduces you to the len function. There is actually an easier way to access the last item on the string: >>>s[-1] ‘n’ To access the penultimate character: >>>s[-2] ‘o’

TYPES OF STRINGS Single Line Strings Strings created using a single quote or double quote must end in one line and are called single-line strings For Example: Item=“Computer” Or Item= ‘Computer’ Multi-Line Strings Strings created using a single quote or double quote and spread across multiple lines are called Multi-Line Strings. By adding backslash \ one can continue to type on the next line. For instance: Item = ‘Key\ board’ PAGE 10

STRINGS WITH TRIPLE QUOTES PAGE 11 For multi-line strings created by triple quotes, while calculating size, the EOL(End of Line) character at the end of the line is also counted. For instance: Str2=“’x y Z”’ Enter keys are considered as EOL so size of str2 is 5

ESCAPE SEQUENCES PAGE 12 \\ \’ \” \n \r

\\

PAGE 14 \’ \’

PAGE 15 \”

PAGE 16 \n

PAGE 17 \r

COMMENTS IN PYTHON PAGE 18 Comments are nonexecutable statements in a program. Single line comment always starts with # Multiline comments will be in triple quotes. For example: “’ Write a program to find the simple interest “’. Note: Triple quotation is called docstrings.

PAGE 19 What is Token? Individual elements that are identified by programming language are called tokens or lexical unit.

PAGE 20 Any Questions Please

HOMEWORK PAGE 21 Write some uses of Python in the real world. What do you understand by dynamic programming language? What is the use of \n in Python? Calculate the length of the string “PROGRAMMING LANGUAGE”. Comments are _________________ statements.
Tags