# PYTHON IN ONE SHOT
Timestamps :
- Introduction
- Install Python (Windows & Mac - both)
- Install PyScripter (only for Windows)
- How to work with PyScripter?
- Install PyCharm (Windows & Mac - both)
- Creating a file
- 1st Program (Output)
- Variables
- Exercise 1
- Input
- Concatenation
- Exercise 2
- Type Conversion
- Print Sum of 2 Numbers
- Strings
- Keywords
- Arithmetic Operators
print("Hello World")
# It is a case sensitive language
# variables
# boolean, integer, floaten, strings
#example 1 simple variable
name = "shradha"
age = 22
print(name)
print(age)
#example 2 how to change name and age
name = "shradha"
age = 22
name = "aman"
age = 24
print(name)
print(age)
#example 3 define variables with boolean type
first_name = "shradha"
last_name = "khapra"
age = 19
is_adult = True
print(first_name + " " + last_name)
print(age)
print(is_adult)
""" Exercise
* Add a person with name Tony Stark.
* Tony's age is 51
* Tony is a genius. """
# Exercise Solution
first_name = "Tony"
last_name = "Stark"
age = 51
is_genius = True
print(first_name + " " + last_name)
print(age)
print(is_genius)
# Taking input
name = input("what is your name ?")
print("Hello " + name)
print("Welcome to our cool python class")
""" Exercise
* Tony is secretely a Superhero. Ask him for his
superhero name & show it on the terminal."""
# Exercise Solution
superhero = input("what is your superhero name ?")
print(superhero)
# Type conversion
old_age = input("Enter your age : ")
#new_age = (old_age) + 2
#print(new_age)
new_age = int(old_age) + 2
print(new_age)
#useful conversion functions
# 1. float()
# 2. bool()
# 3. str()
# 4. int()
# code for sum of 2 Numbers
first_number = input("Enter 1st number : ")
second_number = input("Enter 2nd number : ")
sum = float(first_number) + float(second_number)
print("the sum is : " + str(sum))
# Strings
name = "Tony Stark"
print(name.upper())
print(name)
print(name.lower())
print(name)
print(name.find('y'))
print(name.find('Y'))
print(name.find("Stark"))
print(name.find("stark"))
print(name.replace("Tony Stark", "Ironman"))
print(name)
print(name.replace("Stark", "Ironman"))
# Arthmetic operators
print(5 + 2)
print(5 - 2)
print(5 * 2)
print(5 / 2)
print(5 // 2)
print(5 % 2)
print(5 ** 2)
i = 5
i = i + 5
i += 2
i -= 2
i *= 2
No comments:
Post a Comment