0% found this document useful (0 votes)
13 views7 pages

Coding Notes

The document provides an overview of basic Python programming concepts including variables, data types, arithmetic operations, and control structures. It includes examples of input/output operations, conditionals for checking even/odd numbers, age, grades, and maximum values, as well as loops and lists. Additionally, it covers functions for calculating area, perimeter, and temperature conversions.

Uploaded by

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

Coding Notes

The document provides an overview of basic Python programming concepts including variables, data types, arithmetic operations, and control structures. It includes examples of input/output operations, conditionals for checking even/odd numbers, age, grades, and maximum values, as well as loops and lists. Additionally, it covers functions for calculating area, perimeter, and temperature conversions.

Uploaded by

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

#To make a comment without interfearing with your coding

= # print("hello"

#variable

a = 80
b = 40
print(a+b)

#data type
1. integer= int = 7,90,765 (no decimal)
2. float = 1.0. 10.89c,50.0
3.string=str="70" '70.0' . "hello" . '@hi'

#reason for data

a = 80.5
b = '40'

if we use 80.5 with '40' it wont work so

a = 80.5
b = 40

# we cant mix string and foat and integer but it can only multiply
example

a = 5
b= "40"
print(a*b)

variable

a = 5
a = 2
a = 7
b = 40
print(a*b)

the ans will be 40 times 7 because the 1 and 2 number has been gone and has been
replaced by 7

#vARIABLE naming rules

1. must start with a letter or a _ example- asad or _asad


2. a variable number cant start with a number example - 1asad or 60asad
3.A variable name can only contain alpha-numeric characters and underscores (A-z,
0-9, and _ )
4.A variable name can only contain alpha-numeric characters and underscores (A-z,
0-9, and _ )
Variable names are case-sensitive (age, Age and AGE are three different variables)
5.A variable name cannot be any of the Python keywords.

#arithmetic operator

# + - * / % ** //

#arithmetic operation

a=10
b=3
print("addition=", a+b)
print("Substraction=", a-b)
print("Divition=", a/b)
print("multiplicatiobs=", a*b)
print("Modulasl=", a%b)
print("Exponentia=", a**b)
print("Floor Divition=", a//b)

#fun

a=input("Enter your 1st number: ")


b=input("Enter your 2nd number: ")
print(a=b)

#basic calculator

a=int(input("Enter your 1st number: "))


b=int(input("Enter tour 2nd number: "))

#to give all arthiemc opetetor togethor

a=int(input("Enter your 1st number: "))


b=int(input("Enter tour 2nd number: "))
print("addition=", a+b)
print("Substraction=", a-b)
print("Divition=", a/b)
print("multiplicatiobs=", a*b)
print("Modulasl=", a%b)
print("Exponentia=", a**b)
print("Floor Divition=", a//b)

#Even or odd checker


num = int(input("enter a number: "))

if num % 2==0:
print("its an odd number")
else:
print("its an even number")

#Age checker

age = int(input("Enter your age")

if age >= 18:


print("your a child")
else:
print("your a kid")

# Grade Checker

score = int(input("Enter your score: "))

if score >= 80:


print("Grade A+")
elif score >= 70:
print("Grade A")
elif score >= 60:
print("Grade A-")
elif score >= 50:
print("Grade B")
elif score >= 40:
print("Grade C")
elif score >= 33:
print("Grade D")
else:
print("Grade F")

#Check if number is negetive or positive

number = int(input("enter a number: "))

if number > 0:
print("This is a positive number")
elif number < 0:
print("this is a Negetive number")
else:
print("the number is zero")

#ap string
ten = int(input("Enter your first number: "))
twenty = int(input("Enter your second number: "))
sum = ten + twenty
print(f"Sum of {ten} and {twenty} is {sum}")

#perimeter

length = int(input("Enter length: "))


breadth = int(input("Enter breadth: "))
perimeter = 2*(length+breadth)
print(f"Perimeter of rectangle is {perimeter}")

#area

length = int(input("Enter Length: "))


breadth = int(input("enter breadth: "))
area = length * breadth
print(f"Area of rectangle is {area}")

#uidk

Centimeters = int(input("enter length: "))


meters = Centimeters / 100
kilometer = Centimeters / 100000
print(f" Length in meters: {meters}" )
print(f"Length in kilometer: {kilometer}" )

#Fahrenheit Converter

Celcius = int(input("Enter Temperature: "))


Fahrenheit = (Celcius * 9/5) + 32
print(f"Temerature in Fahrenheit is: {Fahrenheit}" )

#Celcius converter

Fahrenheit = float(input("Enter Tempreture: "))


Celcius = (Fahrenheit - 32) * 5/9
print(f"Temperature in celsius is {Celcius}")

#Whats the bigger number


a = int(input("Enter your number: "))
T = int(input("Enter your second number: "))
A = int(input("Enter your Third Number: "))
B = int(input("Enter Your Forth number: "))
if a > T and a > A and a > B:
print(f"Maximum Number is {a}" )
elif T > A and T > B:
print(f"Maximum Number is {T}" )
elif A > B:
print(f"Maximum number is {A}" )
else:
print(f"Maximum number is {B}" )

#What nu8mber is Divisible

Number = int(input("Enter Your First Number: "))

if Number % 5 == 0 and Number % 11 == 0:


print(f"Number is divisible by 5 and 11")
else:
print(f"Its not Possible")

#Next We Will start nested condition and loop

#Write a C program to check whether a character is alphabet or not.

A = input("Enter Your Character: ")

if A.isalpha():
print(f"{A} is a Alphabet")
else:
print(f"{A} is not a Alphabet")

#Write a python program to input any alphabet and check whether it is vowel or
consonant.

L = input("Enter Your Charactar: ")


if L in "aeiou":
print("Vowel")
else:
print("Consonant")

Write a C program to input any character and check whether it is alphabet, digit or
special character.

#Write a C program to check whether a character is uppercase or lowercase alphabet.


Ch = input("Enter Your character: ")

if Ch.isalpha():
if Ch.isupper():
print("This Character Is Upper Case")
elif Ch.islower():
print("This Character is Lower Case")
else:
print("This is not a character")

#Write a C program to input week number and print week day.

week = int(input("Enter Your Number: "))

if week == 1:
print("Monday")
if week == 2:
print("Tuesday")
if week == 3:
print("Wednesday")
if week == 4:
print("Thursday")
if week == 5:
print("Saturday")
if week == 6:
print("Friday")
if week == 7:
print("Sunday")

#loop

while True:
print("hello")

#loop 1 - 100

n = 1
while n <= 100:
print(n)
n += 1

#weird loop

x="abdullah"
for i in x:
print(i)

#sir silibus
DO LIST HAHAHA topic = list

#list example

score=[10,70,90]
x=9
print(score[7]+9)

#loop list

score=[10,70,90]
for i in score:
print(i)

#loop list addition

score=[10,70,90]
for i in score:
print(i)
add=add+i
print(add)

#item checker

score+[10,80,80,65,54,36]
print(len(score))

#type

score+[10,80,80,65,54,36]
x=10
count=type(score)
print(count)

You might also like