Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Ac circuits

Rating
-
Sold
-
Pages
14
Uploaded on
21-12-2024
Written in
2024/2025

provides details about Ac circuits

Institution
Course

Content preview

Python Tutorial
Fundamentals of Loops in Python:
For Loops
• Initialization of counter variable
• Condition check for continuation of loop
• Increment/decrement of counter variable
While Loops
• Initialization of condition variable
• Evaluation of condition in while statement
• Updation of condition variable
List Operations
• Creating lists using square brackets
• Accessing list elements using indexing
• Modifying list elements
Nested Loops
• Loop inside a loop
• Outer loop controls the number of times inner loop is executed
Factorial Calculation
• Implementing the formula using loops
Conditional Statements
• Checking for a given condition
• Executing a block of code based on the condition

,Error Handling
• Detecting various errors in the program
• Handling the errors using try and except blocks
Understanding Variables
• Storing values in variables
• Understanding data types of variables
• Rules for naming variables in Python
Functions and Modules
• Defining a function
• Calling a function
• Importing modules in Python programs



Working with Numbers:
Even, Odd, and Prime Number Identification (Python Classes
and Objects)
Understanding Variables and Data Types in Programming
Before diving into number identification, it's important to
understand variables and data types in programming, including:
• Scalar data types (int, float, bool, str)
• Compound data types (list, tuple, dictionary, set)
• Assigning values to variables
Even, Odd, and Prime Number Identification
Even Numbers

, • Even numbers can be identified by checking if the remainder of
the number divided by 2 is 0.
if num % 2 == 0:
print(f"{num} is an even number.")
Odd Numbers
• Odd numbers can be identified by checking if the remainder of
the number divided by 2 is not 0.
if num % 2 != 0:
print(f"{num} is an odd number.")
Prime Numbers
• Prime numbers are numbers greater than 1 that have only 2
factors: 1 and itself.
def is_prime(num):
if num < 2:
return False
for i in range(2, num):
if num % i == 0:
return False
return True


if is_prime(num):
print(f"{num} is a prime number.")
File Input and Output Operations
• Useful for reading and writing data to external files.
# Reading from a file

Written for

Institution
Course

Document information

Uploaded on
December 21, 2024
File latest updated on
December 22, 2024
Number of pages
14
Written in
2024/2025
Type
Class notes
Professor(s)
.
Contains
All classes

Subjects

$5.39
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
hp3329353

Get to know the seller

Seller avatar
hp3329353 Anna University
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions