Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This repository is aimed at learning the basics of Python Programming Language

NotificationsYou must be signed in to change notification settings

popoolaio/Basics-of-Python-Programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

This repository is aimed at learning the basics of Python Programming Language

Table of Contents

  1. Variable
  2. Data Types
  3. Operators
  4. Expression

Variable

Dynamic Typing:

x=10# Integername="Alice"# Stringpi=3.14# Floatis_active=True# Boolean

Reassignment:

x=10# Integerx="Ten"# Now a String

Descriptive Names:

user_age=25total_price=100.50

Naming Conventions:

  • Use descriptive names to make your code readable
user_age=25total_price=100.50
  • Variable names must start with a letter or an underscore _, but cannot start with a number.
  • Avoid using reserved keywords (e.g., if, for, while) as variable names.
  • Use snake_case for multi-word variable names (e.g., user_name, total_amount).

Multiple Assignments:

Python allows assigning multiple variables in a single line.

x,y,z=1,2,3

You can also assign the same value to multiple variables:

a=b=c=5

Printing Variables:

Use the print() function to display variable values.

name="Alice"age=25print("Name:",name)print("Age:",age)

Output

Name:AliceAge:25

Data Types

Python variables can store different types of data. These data types include:

  1. Integer(int): Whole numbers
age=30
  1. Floating Point(float): Decimal numbers
price=19.99
  1. String(str): Textual data
name="Alice"
  1. Boolean(bool): True or False values
is_active=True
  1. List, Tuple, Dictionary: Collections of data
numbers= [1,2,3]# Listcoordinates= (4,5)# Tupleuser= {"name":"Alice","age":25}# Dictionary

Operators

Arithmetic Operators

a=10b=3print(a+b)# Output: 13print(a**b)# Output: 1000 (10 raised to the power of 3)

Comparison Operators

print(a>b)# Output: Trueprint(a==10)# Output: True

Logical Operators

print(a>5andb<5)# Output: Trueprint(not(a<5))# Output: True

Assignment Operators

x = 5x += 3print(x) # Output: 8

Membership Operators

fruits= ["apple","banana","cherry"]print("banana"infruits)# Output: Trueprint("grape"notinfruits)# Output: True

Expression

Example of an expression:

2+3# This expression evaluates to 5a*b# If a = 4 and b = 5, this evaluates to 20

Examples of Expressions

  • Arithmetic Expression:
result= (4+5)*2# Evaluates to 18
  • Logical Expression:
is_valid= (5>2)and (3<4)# Evaluates to True
  • String Expression:
full_name="John"+" "+"Doe"# Evaluates to "John Doe"
  • Lambda Expression:
add=lambdax,y:x+yprint(add(3,4))# Evaluates to 7

About

This repository is aimed at learning the basics of Python Programming Language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp