0% found this document useful (0 votes)
23 views

Python Codes

This document contains Python code examples demonstrating various Python programming concepts including: 1) Printing strings and expressions, defining and printing variables, taking user input and performing operations on input data types. 2) If/else conditional statements to check conditions and print corresponding outputs. 3) Logical operators like and, or, not in conditional statements. 4) String methods like upper(), lower(), find(), replace(), len() applied to course strings. So in summary, it covers Python basics like variables, data types, string operations, conditional statements and logical operators through multiple code examples.

Uploaded by

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

Python Codes

This document contains Python code examples demonstrating various Python programming concepts including: 1) Printing strings and expressions, defining and printing variables, taking user input and performing operations on input data types. 2) If/else conditional statements to check conditions and print corresponding outputs. 3) Logical operators like and, or, not in conditional statements. 4) String methods like upper(), lower(), find(), replace(), len() applied to course strings. So in summary, it covers Python basics like variables, data types, string operations, conditional statements and logical operators through multiple code examples.

Uploaded by

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

#print("Zahra Jani")

#print('0----')
#print(' ||||')
#print('*' * 10) #this is called an expression
#price = 10
#price = 20
#rating = 4.9
#name="Mom"
#published = True
#print(price)

#PatientName = "John Smith"


#Age = 20
#New = True
#ExistedPatient = False
#print("Patient Name: " ,PatientName)
#print("Age: ", Age)
#print("New Patient: ", New)
#print("Existed Patient: " ,ExistedPatient)

#name = input('What is your name? ')


#color = input('What is your favorite color? ')
#print(name + " likes " + color + " color.")

#birth_year = input('Please Enter Your Birth Year: ')


#print(type(birth_year), " This shows the data type of Birth year")
#Age = 2023 - int(birth_year)
#print("You are", Age, "years old")
#print(type(Age), "This one shows data type of Age")

#Weight_Pound =input("Please tell us your weight: ")


#Conversion = float(Weight_Pound) * 0.45
#print("Your weight in pounds is ", Weight_Pound, "which equals to ",
Conversion, "Kilograms")

#Course = "The double quotes can be used to use single quotes as a text. E.g,
it's an example and vice versa"
#Course2 = 'We can use double quotes as a text in between the single ones
"like this" it is counted as a text'
#Course3 = '''Also use three single quotes for multiple line strings

#Hello Zahra,
#This is an example for three single quotes used for multiple line strings.
#Hope you understand it.

#Regards,
#Hussainzada'''
#print(Course)
#print(Course2)
#print(Course3)

#program = " This is a program for beginners "


#print("If you use brackets; you can show any letter from a whole string. Like
the text above. From left to right 0123...",
# program[-2])
#print("Use : inside [] to show from which character up to which character
should be printed ", program[2:6])
#print("Also if you give a number on the left side of : it will print all the
characters except that one specific",
# program[2:])
#print("The [:] means the copy of your characters", program[:])
#name = 'Jennifer'
#print(name[1:-1])

#format string f and {} use it dynamically


#Name= input("Name: ")
#L_Name= input("Last Name: ")
#message= Name + ' ['+L_Name+'] is a coder'
#MSG=f'{Name} [{L_Name}] is a coder'
#print(MSG)

#course =' Python for Beginners'


#print(len(course))
#print(course.upper())
#print(course.lower())
#print(course.find("for"))#finds the index of the characters For
#print("for" in course)
#print(course.replace("Beginners","Everyone"))
#print(course.title)

#Arithmetic Operations
#print(10*3) #zarb
#print(10/3) #taqsim
#print(10+4)#jam
#print(10//3)#baqimanda
#print(10**3)#ba tawana
#x=10
#x=x+3
#x+=3#augmented assign operator the same like x=x+3 you can use - or * instead
of + the same way
#print(x)
#print(10+3*2)#operator precedent

#x=2.5
#y=-2.8
#print(round(x))
#print(abs(y))
#import math
#can be used to import all math libraries and use it in python
#also we can search on google 'python 3 math module'

#if statements
#weather= True

#if weather:
# print("It is a hot day")
# print("Don't forget sunscreen")

#else:
# print("Lucky you it is a cold day")
# print("Wear warm clothes")
#print("Have a nice day")

#is_hot= False
#is_cold= True
#if is_hot:
# print("It is a hot day")
# print("Don't forget sunscreen")
#elif is_cold:
# print("Wear warm clothes")
#else:
# print("Such a nice weather")
#print("Enjoy your day")

#house_price= 1000000
#good_credit=False
#bad_credit= False
#if good_credit:
# calculation= (int(house_price) * 10)/100
# print('you have put down 10% which equals to', int(calculation))
#elif bad_credit:
# calculate=(int(house_price) * 20)/10
# print("You have to put down 20% which equals to: ", int(calculate))
#else:
# print("Seems like It doesn't work")
# print("Sorry, better luck next time")
#print("see you")

#logical AND OR NOT


#has_goodcredit= True
#has_highincome= True
#criminal_record= False
#if has_highincome and has_goodcredit and not criminal_record:
# print("You are Eligible!")
#elif has_highincome or has_goodcredit:
# print("We don't have Financial support, but the program is available for
you")
#else:
# print("I am sorry you are not eligible")

#temperature= 50
#if temperature>27:
# print("It is a hot day today!")
#elif temperature<=20:
# print("Isn't it a bit cold?")
#elif temperature==50:
# print("It is burning everyone down!")
#elif temperature!=50: #not equal\
# print("It is good it is not that high!")
#else:
# print("It is such a nice weather!")
#print("Enjoy your day")

#name= input("Please enter your name?")


#if len(name)<=3:
# print("You have to Enter at least four characters:")
#elif len(name)>=50:
# print("Your name length must not exceed 50 characters.")
#else:
# print("It is all good!")

You might also like