0% found this document useful (0 votes)
55 views6 pages

My Python First Day Notesbook

The document provides an introduction to Python programming basics through a series of code examples in Jupyter Notebooks. It covers topics like printing output, operators, variables, data types, input functions, conditional logic, loops, functions, importing libraries and troubleshooting. The examples demonstrate how to write simple Python code, work with data types, use basic programming constructs and import commonly used libraries.

Uploaded by

Ziao Rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views6 pages

My Python First Day Notesbook

The document provides an introduction to Python programming basics through a series of code examples in Jupyter Notebooks. It covers topics like printing output, operators, variables, data types, input functions, conditional logic, loops, functions, importing libraries and troubleshooting. The examples demonstrate how to write simple Python code, work with data types, use basic programming constructs and import commonly used libraries.

Uploaded by

Ziao Rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Python ka chilla with baba Aammar

# how to use jupyter Note book


Basics of Python
1- My first program

01- My first program


In [1]: print("python_with_Ammar")
print("we are learning python with Ammar")

print(45*25)

python_with_Ammar

we are learning python with Ammar

1125

02_operators
In [2]: print(2+2)

print(3-2)

print(6/2)

print(2*3)

print(13%2)

print(6//2)

print(2**3)

print(2**2/2*3/3+6-4)

#PEAMDAS

# parenthasis Exponents Multiply Divide Addition Subdtraction

# Left to sequence for M D & A S

3.0

4.0

03-Strings
In [3]: print("Hello world")

print("We are learning with Ammar")

Hello world

We are learning with Ammar

05- Variables
In [4]: # Variables: objects containing specific values

x = 5

print(x) # numeric or integer variables

y = "we are learning python with Ammar" #String variables

print(y)

x = x+10

print(x)

#types of variables

type(x)

print(type(y))

# Rules to assign a variable

# 1- The variable Should contain letters, numbers or Underscores

# 2- Do not start with numbers

# 3- Spaces are not Allowed

# 4- Do not use Keywords used in functions (break, mean, media, test etc)

# 5- short and descriptive

# 6- Case sensitivity (Lowercase, uppercaseletters, lowercase letters is recommended)

fruitbasket= "Mangos"

print(fruitbasket)

we are learning python with Ammar

15

<class 'str'>

Mangos

06-Input_Variables
In [ ]: #fruit_basket ="Mangos"

#print(fruit_basket)

#input function simple

# fruit_basket = input("Which is your favourite fruit?")

# print(fruit_basket)

#input function of 2nd stage

# name =input("what is your name? ")

# greetings = "Hello!"

# print(greetings, name)

#Another way of stage 2 input function

# input function of 2nd stage

# name =input("what is your name? ")

# print("Hello!", name)

#3rd stage input function

name= input("what is your name?")


age = input("how old are you?")

greetings = "Hello!"

print(greetings, name, ", You are still young")

07-Conditional_logics
In [ ]: ### Logical Operators mentioned below

### logical operators are either "true or false" or "yes or No" or "0 or 1"

### Equal to ==

### not equal to !=

### great than <

### less than and equal to <=

### greater than and equal to >=

### is equal to?

### print(4==4)

### application of logical operators

### hamad_age = 4

### age_at_school = 5

### print(hamad_age==age_at_school)

### input funcion and logical operator

hamad_age = 4

age_at_school = 5

hamad_age = input("how old is hamad? ") #input function

hamad_age=int(hamad_age)

print(type(hamad_age))

print(hamad_age==age_at_school) #logical operator

08-Type_conversion
In [ ]: # from unicodedata import name

# x = 10 # integer

# y = 10.2 # float (with disassemble)

# z = "Hello" # string

# implicit type conversion

# x = x+y

# print(x,"type of x is:", type(x))

# exlicit type conversion

# age = input("What is your age? ")

# age = int(age)

# print(age, type(float(age)))

# name

from zipapp import ZipAppError

name = input("what is your name? ")

print(name,type(str(name)))

09-If_else_elif
In [ ]: requird_age_at_school = 5

hammad_age =2

# question : can hammad go to school

if hammad_age == requird_age_at_school:

print("hammad can join the school.")

elif hammad_age > requird_age_at_school:

print("Hammad should join high school.")

print("hammad can not go to school.")

elif hammad_age <= 5:

print("you should take care of hammad, he is still a baby!")

else:

print("hammad can not go to school.")

10-Functions
In [ ]: # definig a function

# def print_codanics():

# print("We are learning with Ammar.")

# print("We are learning with Ammar.")

# print("We are learning with Ammar.")

# print_codanics()

# 2

# def print_codanics():

# text = "we are learning with Aammar in codanics youtube channel"

# print(text)

# print(text)

# print(text)

# print_codanics()

# 3

# def print_codanics(text):

# print(text)

# print(text)

# print(text)

# print_codanics("We are learning python with Ammar in codanics youtube channel")

# defining a function with if elif else statements

# def school_calculator(age, text):

# if age == 5:

# print("Hammad can join the school")

# elif age > 5:

# print("Hammad should go to high school")

# else:

# print("Hammad is stil a baby")

# school_calculator(1,"Hammad")

# dfining a function of future

def fg(age):

new_age = age + 20

return new_age

print(new_age)

future_predicted_age= fg(18)

print(future_predicted_age)

11-Loops
In [ ]: # while loops and For loops

# while loops

# x = 0

# while (x<5):

# print(x)

# x = x + 1

# for loop

# for x in range(5,10):

# print(x)

# array

days = ["mon", "tue","wed", "thu", "Fri", "sat", "sun"]

for d in days:

if (d=="Fri"):break #loop stops

# if (d=="Fri"): continue #skips d

print(d)

12-Import_libraries
In [ ]: #### if you want to print the value of pi

import math

print("The value of pi is ", math.pi)

import statistics

x = [150,250,350,450]

print(statistics.mean(x))

#### important libraries: numpy, pandas

13-Trouble_shouting
In [ ]: # if you want to print the value of pi

import math

print("The value of pi is ", math.pi)

import statistics

x = [150,250,350,450]

print(statistics.mean(x))

# important libraries: numpy, pandas

You might also like