0% found this document useful (0 votes)
13 views12 pages

VisualStudio Python Lab With Code

Uploaded by

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

VisualStudio Python Lab With Code

Uploaded by

Vijay Kanavi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Python Programming in Visual

Studio IDE
Lab Session for Automation &
Robotics Department
Instructor: [Your Name]
Objectives

• Learn to create and configure Python projects


in Visual Studio
• Write programs for Velocity & Wheel
Rotations
• Run, compile (interpret), and debug code
• Handle input/output for robotics applications
• 📸 Placeholder: Robot + coding diagram
Visual Studio IDE for Python

• Rich editor (syntax highlighting, IntelliSense)


• Built-in debugging tools
• Supports multiple Python environments
• Used in robotics for structured development
• 📸 Screenshot Placeholder: Visual Studio
'Create New Project' screen
Project Properties

• Choose Python interpreter


• Set startup file (velocity_calculator.py)
• Manage libraries (math, numpy, pyserial)
• 📸 Screenshot Placeholder: Python
Environment Selection window
• 📸 Screenshot Placeholder: Solution Explorer
with project files
Program Example: Velocity
Calculator
distance = float(input("Enter distance (m): "))

time = float(input("Enter time (s): "))

if time == 0:

print("Error: Time cannot be zero.")

else:

velocity = distance / time


• print(f"Velocity = {velocity} m/s")
Program Example: Wheel Rotation
Calculator
import math

wheel_radius = 0.05 # meters

distance_to_travel = float(input("Enter distance to travel (m):


"))

circumference = 2 * math.pi * wheel_radius

if circumference == 0:

print("Error: Wheel circumference cannot be zero.")

else:

rotations = distance_to_travel / circumference


• print(f"Wheel rotations required = {rotations:.2f}")
Running the Program

• Python is interpreted (no compile step)


• Run with:
• • F5 = Run with debugging
• • Ctrl + F5 = Run without debugging
• 📸 Screenshot Placeholder: Terminal showing
program output
Debugging the Program

• Breakpoints → pause program


• Step Into/Over → run line by line
• Watch Window → inspect variables
• 📸 Screenshot Placeholder: Breakpoint at
'velocity = distance / time'
• 📸 Screenshot Placeholder: Variables panel
showing values
Input & Output

• Input: via keyboard, file, or sensor (serial)


• Output: console, logs, motor controller
commands
• 📸 Placeholder: Diagram of Robot (sensor →
Python program → motor output)
Example Lab Workflow

• 1. Create project 'RoboticsLab'


• 2. Add velocity_calculator.py
• 3. Run & test with distance = 10 m, time = 2 s
• 4. Debug with time = 0
• 5. Add wheel_rotation.py
• 📸 Screenshot Placeholder: Step-by-step
sequence (project → run → debug)
Robotics Applications

• Velocity Calculator: controls robot speed


• Wheel Rotation Calculator: precise navigation
• Debugging: prevents runtime errors during
movement
• 📸 Placeholder: Robot wheel + motion diagram
Conclusion

• Visual Studio IDE → structured, safe Python


development
• Students learn programming, debugging, I/O
• Direct robotics relevance: motion control,
navigation, safety

You might also like