Posted in

python new course, ” variable-2″, Python Basic Notes (Beginner), hindi

 


Python Basic Notes (Beginner)

1. Data Types in Python

Integer

Whole numbers को Integer कहते हैं।

print(7)

Output

7


Float

Decimal numbers को Float कहते हैं।

print(7.5)

Output

7.5


String

Text को String कहते हैं। Python में string को ” “ , ‘ ‘ या ”’ ”’ में लिखा जा सकता है।

print(“hello world”)

print(‘hello world’)

print(”’hello world”’)

Output

hello world

hello world

hello world


String with Quotes

print(“‘hello world'”)

Output

‘hello world’

print(‘”hello world”‘)

Output

“hello world”


Boolean

Boolean में केवल दो values होती हैं।

True

False


2. Variable in Python

Variable एक container होता है जिसमें data store किया जाता है।

Example

x = “Sajid”

y = 7

z = 7.5

print(x)

print(z)

Output

Sajid

7.5


3. Algorithm

Algorithm किसी problem को solve करने के लिए step-by-step instructions होती हैं।

Example:

  1. Start

  2. Input values

  3. Process the values

  4. Display result

  5. End


4. Flowchart

Flowchart algorithm को diagram की form में दिखाता है।

Example problem: Length और Breadth से Rectangle का Area निकालना

Steps

  1. Start

  2. Input Length

  3. Input Breadth

  4. Area = Length × Breadth

  5. Print Area

  6. End


5. Correct Sequence (Computer Start Steps)

नीचे दिए गए steps को सही क्रम में arrange करें:

Correct order:

  1. Switch on the main power supply

  2. Press the power button of CPU

  3. Wait for the desktop screen

  4. Enter the password

  5. Open a program


6. Input Function Example

x = input(“Enter your name: “)

print(x, “- Welcome to Python Programming”)

Example Output

Enter your name: Sajid

Sajid – Welcome to Python Programming


7. Country Example

name = input(“Enter your name: “)

country = input(“Enter name of the country: “)

print(“Welcome”, name)

print(“Your country”, country, “is a beautiful country”)


8. Sum of Three Numbers

x = int(input(“Enter the first number: “))

y = int(input(“Enter the second number: “))

z = int(input(“Enter the third number: “))

print(“The sum of three numbers =”, x + y + z)


9. Calculator Program

x = float(input(“Enter the first number: “))

y = float(input(“Enter the second number: “))

print(“Addition:”, x + y)

print(“Subtraction:”, x – y)

print(“Multiplication:”, x * y)

print(“Division:”, x / y)


10. First Name and Last Name Program

first_name = input(“Enter the first name: “)

last_name = input(“Enter the last name: “)

print(“Hello”, first_name, last_name, “welcome to the Python program”)


11. If-Else Example

x = int(input(“Enter the money received: “))

if x >= 100:

   print(“Buy a cake”)

elif x >= 50:

   print(“Buy biscuits”)

elif x >= 40:

   print(“Buy chocolate”)

else:

   print(“Don’t buy anything”)


12. Even or Odd Program

x = int(input(“Enter the value: “))

if x % 2 == 0:

   print(“Even”)

else:

   print(“Odd”)


13. String Concatenation Example

first_name = “Sajid”

last_name = “Sheikh”

full_name = first_name + ” ” + last_name

print(“Hello, ” + full_name.title() + “!”)

Output

Hello, Sajid Sheikh!


14. Using Variable

first_name = “Sajid”

last_name = “Sheikh”

full_name = first_name + ” ” + last_name

message = “Hello, ” + full_name.title() + “!”

print(message)


15. Simple Concatenation

x = “sajid”

y = “sheikh”

z = x + ” ” + y

print(“Hello ” + z.title() + “!”)


16. New Line and Tab Space

Tab Space

print(“\tsajid”)

print(“\t\tsajid”)

Output

   sajid

       sajid


New Line

print(“sajid”)

print(“\nsajid”)

Output

sajid

sajid


Multiple Languages

print(“python\nc\nc++\njava”)

Output

python

c

c++

java


Tab with Languages

print(“Language:\n\tpython\n\tc\n\tc++\n\tjava”)

Output

Language:

   python

   c

   c++

   java


17. rstrip() Function

rstrip() right side के extra spaces को remove करता है।

first_lan = “python  “

sec_lan = “python”

print(first_lan == sec_lan)

Output

False

Space remove करने के बाद

third_lan = first_lan.rstrip()

print(third_lan == sec_lan)

Output

True


18. Integer to String Conversion

age = 23

message = “Happy ” + str(age) + “rd birthday”

print(message)

Output

Happy 23rd birthday



Leave a Reply

Your email address will not be published. Required fields are marked *