Python programming basic course
Python programming basic course
Many Free Stuffs At last
Variables and Data Types:
- Variables are used to store data values. Python has various data types including integers, floats, strings, lists, tuples, dictionaries, etc.
- Example:python
# Variable assignment x = 5 y = "Hello" z = [1, 2, 3] # Printing variables print(x) # Output: 5 print(y) # Output: Hello print(z) # Output: [1, 2, 3]
Control Flow:
- Control flow statements like if-elif-else and loops (for, while) are used to control the execution of code.
- Example:python
# If-else statement age = 18 if age >= 18: print("You are an adult") else: print("You are a minor") # For loop fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(fruit) # While loop i = 0 while i < 5: print(i) i += 1
Functions:
- Functions are reusable blocks of code that perform a specific task. They can take parameters and return values.
- Example:python
# Function definition def greet(name): return "Hello, " + name # Function call print(greet("Alice")) # Output: Hello, Alice
Lists:
- Lists are ordered collections of items, which can be of different data types. They are mutable, meaning their elements can be changed.
- Example:python
# List creation numbers = [1, 2, 3, 4, 5] # Accessing elements print(numbers[0]) # Output: 1 # Modifying elements numbers[0] = 10 print(numbers) # Output: [10, 2, 3, 4, 5]
Dictionaries:
- Dictionaries are unordered collections of key-value pairs. They are mutable and can store different data types.
- Example:python
# Dictionary creation person = {"name": "John", "age": 30, "city": "New York"} # Accessing values print(person["name"]) # Output: John # Modifying values person["age"] = 35 print(person) # Output: {'name': 'John', 'age': 35, 'city': 'New York'}
- Sum of Numbers in a List:
- This program calculates the sum of numbers in a given list.
pythonnumbers = [10, 20, 30, 40, 50]
total = sum(numbers)
print("Sum of numbers:", total)
- Factorial of a Number:
- This program calculates the factorial of a given number using recursion.
pythondef factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
num = 5
print("Factorial of", num, "is:", factorial(num))
- Palindrome Check:
- This program checks if a given string is a palindrome or not.
pythondef is_palindrome(s):
return s == s[::-1]
string = "radar"
if is_palindrome(string):
print(string, "is a palindrome")
else:
print(string, "is not a palindrome")
- Fibonacci Series:
- This program generates the Fibonacci series up to a specified number of terms.
pythondef fibonacci(n):
fib_series = [0, 1]
for i in range(2, n):
next_term = fib_series[-1] + fib_series[-2]
fib_series.append(next_term)
return fib_series
terms = 10
print("Fibonacci series up to", terms, "terms:", fibonacci(terms))
- Prime Number Check:
- This program checks if a given number is prime or not.
pythondef is_prime(n):
if n <= 1:
return False
elif n <= 3:
return True
elif n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
num = 17
if is_prime(num):
print(num, "is a prime number")
else:
print(num, "is not a prime number")
Free sources very imp : click thisFree STuff 2 : "How to Hunt" most serched keywords regarding basics python - Python basics
- Python beginner course
- Python tutorial for beginners
- Learn Python from scratch
- Python fundamentals
- Introduction to Python
- Python programming basics
- Python crash course
- Python for beginners
- Python programming for beginners
- Python basics tutorial
- Python basics for dummies
- Python basics pdf
- Python basics cheat sheet
- Python basics with examples
- Python basics syntax
- Python basics variables
- Python basics functions
- Python basics loops
- Python basics conditional statements
- Python basics data types
- Python basics strings
- Python basics lists
- Python basics tuples
- Python basics dictionaries
- Python basics sets
- Python basics operators
- Python basics input/output
- Python basics file handling
- Python basics error handling
- Python basics debugging
- Python basics IDE
- Python basics code examples
- Python basics practice exercises
- Python basics quizzes
- Python basics challenges
- Python basics projects
- Python basics online course
- Python basics video tutorial
- Python basics free course
- Python basics paid course
- Python basics certification
- Python basics syllabus
- Python basics curriculum
- Python basics study guide
- Python basics learning path
- Python basics study material
- Python basics resources
- Python basics books
- Python basics websites
- Python basics forum
Post a Comment