Welcome
Comments Comments are useful information that the developers provide to make the reader understand the source code. It explains the logic or a part of it used in the code. There are two types of comment in Python: ● Single line comments: Python single line comment starts with hashtag symbol with no white spaces. Multi-line string as comment: Python multi-line comment is a piece of text enclosed in a delimiter (“””) on each end of the comment.
Headline Subtitle Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.
● Deleting/Updating from a String – ● In Python, Updation or deletion of characters from a String is not allowed because Strings are immutable. Only new strings can be reassigned to the same name.
Mutability and Immutability
Basics of Input/Output Input() and print() name = input('What is your name?n') # n ---> newline ---> It causes a line break print(name) When input() function executes program flow will be stopped until the user has given input. The text or message displayed on the output screen to ask a user to enter an input value is optional i.e. the prompt, which will be printed on the screen is optional. Whatever you enter as input, the input function converts it into a string. if you enter an integer value still input() function converts it into a string. You need to explicitly convert it into an integer in your code using typecasting.
# Program to check input # type in Python num = input ("Enter number :") print(num) name1 = input("Enter name : ") print(name1) # Printing type of input value print ("type of number", type(num)) print ("type of name", type(name1)) It will show the type of input as str
num = int(input("Enter a number: ")) print(num, " ", type(num)) floatNum = float(input("Enter a decimal number: ")) print(floatNum, " ", type(floatNum)) what will it show about the type of input?
# Python Program for # Creation of String # String with single quotes print('Welcome to the GDSC HIT') # String with double quotes print("I'm a Abhishek Pandey") # String with triple quotes print(‘ ‘ ‘ I'm a 3rd year student and I live in a world of “Aliens“ ‘ ‘ ‘ )
# Python Program to Access # characters of String String1 = “Python“ # Printing First character print(String1[0]) # Printing Last character print(String1[-1])
In computer programming, we use the if statement to run a block code only when a certain condition is met. Indentation in Python Indentation is a very important concept of Python because without properly indenting the Python code, you will end up seeing IndentationError and the code will not get compiled. Python indentation refers to adding white space before a statement to a particular block of code. In another word, all the statements with the same space to the right, belong to the same code block If Elif Else
Let’s Create a Guessing game:
Let’s try to implement the following condition For example, assigning grades (A, B, C) based on marks obtained by a student. 1.if the percentage is above 90, assign grade A 2.if the percentage is above 75, assign grade B 3.if the percentage is above 65, assign grade C
Colors, Charts, and Icons While Loop in Python:- In python, a while loop is used to execute a block of statements repeatedly until a given condition is satisfied. And when the condition becomes false, the line immediately after the loop in the program is executed. # Python program to illustrate while loop count = 0 while (count < 3): count = count + 1 print("Hello!") Examples of While Loop with else statement # Python program to illustrate # combining else with while count = 0 while (count < 3): count = count + 1 print("Hello") else: print("In Else Block")
Colors, Charts, and Icons For Loop in Python:- For loops are used for sequential traversal. For example: traversing a list or string or array etc. In Python, there is “for in” loop which is similar to for each loop in other languages. Let us learn how to use for in loop for sequential traversals. # Python program to illustrate # Iterating over range 0 to n-1 n = 4 for i in range(0, n): print(i) output? Decrementing With range(): for i in range(10, -6, -2): print(i) This will start at 10 and count down by 2 until you reach -6, or rather -4 because you don’t include -6. This will start at 10 and count down by 2 until you reach -6, or rather -4 because you don’t include -6.
Colors, Charts, and Icons Nested Loops:- Python programming language allows to use one loop inside another loop. We will use nested loop to print right angle triangle star pattern. Let’s see how this work: for i in range(1, 5): for j in range(i): print(i, end=' ') print() what is end here? # ends the output with a space print("Welcome to", end = ' ') print("GeeksforGeeks", end= ' ') Print statement automatically print a new line after the prompt inside it. To prevent creating new line and to continue with same line we use end=“ ”
Star Patterns:- Example: for i in range(1, 9): for j in range(i): print(“*”, end=' ') print() Python Print Star Patterns 14 Programs https://easycodebook.com/2021/05/python-print-star-pattern-shapes-programs/
Thank You 

gdscpython.pdf

  • 1.
  • 4.
    Comments Comments are usefulinformation that the developers provide to make the reader understand the source code. It explains the logic or a part of it used in the code. There are two types of comment in Python: ● Single line comments: Python single line comment starts with hashtag symbol with no white spaces. Multi-line string as comment: Python multi-line comment is a piece of text enclosed in a delimiter (“””) on each end of the comment.
  • 10.
    Headline Subtitle Lorem ipsum dolorsit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.
  • 11.
    ● Deleting/Updating froma String – ● In Python, Updation or deletion of characters from a String is not allowed because Strings are immutable. Only new strings can be reassigned to the same name.
  • 12.
  • 14.
    Basics of Input/Output Input()and print() name = input('What is your name?n') # n ---> newline ---> It causes a line break print(name) When input() function executes program flow will be stopped until the user has given input. The text or message displayed on the output screen to ask a user to enter an input value is optional i.e. the prompt, which will be printed on the screen is optional. Whatever you enter as input, the input function converts it into a string. if you enter an integer value still input() function converts it into a string. You need to explicitly convert it into an integer in your code using typecasting.
  • 15.
    # Program tocheck input # type in Python num = input ("Enter number :") print(num) name1 = input("Enter name : ") print(name1) # Printing type of input value print ("type of number", type(num)) print ("type of name", type(name1)) It will show the type of input as str
  • 16.
    num = int(input("Entera number: ")) print(num, " ", type(num)) floatNum = float(input("Enter a decimal number: ")) print(floatNum, " ", type(floatNum)) what will it show about the type of input?
  • 17.
    # Python Programfor # Creation of String # String with single quotes print('Welcome to the GDSC HIT') # String with double quotes print("I'm a Abhishek Pandey") # String with triple quotes print(‘ ‘ ‘ I'm a 3rd year student and I live in a world of “Aliens“ ‘ ‘ ‘ )
  • 18.
    # Python Programto Access # characters of String String1 = “Python“ # Printing First character print(String1[0]) # Printing Last character print(String1[-1])
  • 20.
    In computer programming,we use the if statement to run a block code only when a certain condition is met. Indentation in Python Indentation is a very important concept of Python because without properly indenting the Python code, you will end up seeing IndentationError and the code will not get compiled. Python indentation refers to adding white space before a statement to a particular block of code. In another word, all the statements with the same space to the right, belong to the same code block If Elif Else
  • 21.
    Let’s Create aGuessing game:
  • 22.
    Let’s try toimplement the following condition For example, assigning grades (A, B, C) based on marks obtained by a student. 1.if the percentage is above 90, assign grade A 2.if the percentage is above 75, assign grade B 3.if the percentage is above 65, assign grade C
  • 23.
    Colors, Charts, andIcons While Loop in Python:- In python, a while loop is used to execute a block of statements repeatedly until a given condition is satisfied. And when the condition becomes false, the line immediately after the loop in the program is executed. # Python program to illustrate while loop count = 0 while (count < 3): count = count + 1 print("Hello!") Examples of While Loop with else statement # Python program to illustrate # combining else with while count = 0 while (count < 3): count = count + 1 print("Hello") else: print("In Else Block")
  • 24.
    Colors, Charts, andIcons For Loop in Python:- For loops are used for sequential traversal. For example: traversing a list or string or array etc. In Python, there is “for in” loop which is similar to for each loop in other languages. Let us learn how to use for in loop for sequential traversals. # Python program to illustrate # Iterating over range 0 to n-1 n = 4 for i in range(0, n): print(i) output? Decrementing With range(): for i in range(10, -6, -2): print(i) This will start at 10 and count down by 2 until you reach -6, or rather -4 because you don’t include -6. This will start at 10 and count down by 2 until you reach -6, or rather -4 because you don’t include -6.
  • 25.
    Colors, Charts, andIcons Nested Loops:- Python programming language allows to use one loop inside another loop. We will use nested loop to print right angle triangle star pattern. Let’s see how this work: for i in range(1, 5): for j in range(i): print(i, end=' ') print() what is end here? # ends the output with a space print("Welcome to", end = ' ') print("GeeksforGeeks", end= ' ') Print statement automatically print a new line after the prompt inside it. To prevent creating new line and to continue with same line we use end=“ ”
  • 26.
    Star Patterns:- Example: for iin range(1, 9): for j in range(i): print(“*”, end=' ') print() Python Print Star Patterns 14 Programs https://easycodebook.com/2021/05/python-print-star-pattern-shapes-programs/
  • 27.