The provided texts encompass a diverse range of topics, predominantly focusing on Saudi Arabian news and events. A significant portion highlights celebrations and acknowledgements related to the Kingdom’s Founding Day, along with various cultural and sports-related news. Diplomatic relations and international collaborations, particularly in areas like investment and sports, are also featured. Furthermore, the sources touch upon global issues such as the Ukrainian conflict and the Iranian oil industry, demonstrating Saudi Arabia’s engagement with broader international concerns. Economic indicators, particularly regarding non-petroleum exports are spotlighted. The documents also discuss the significance of the Arabic language and literary contributions related to Saudi Arabian culture and heritage.
Saudi Arabia Review and Study Guide
I. Quiz
Answer each question in 2-3 sentences.
According to the text, how does the Kingdom support countries and peoples in need?
What is cited as evidence of the Kingdom’s improved economic performance in the non-oil sectors?
What role does the Kingdom play in global trade, according to the text?
What does the Saudi Founding Day represent, and what significance does it hold for the Kingdom’s identity?
According to the text, what is the Saudi government doing to improve education?
What concerns are driving up oil prices, according to the text?
How did non-oil exports increase in December 2024, compared with December 2023?
According to the text, what is the Heet Union and what challenge does it pose to the Kingdom?
What are the Saudis doing to preserve Architectural heritage, according to the text?
What is one thing that the text says is a symbol of shared values, meanings, and goals for Saudi Arabia?
Quiz Answer Key
The Kingdom provides aid and assistance to countries and peoples most in need and offers relief to those affected by disasters around the world, demonstrating its commitment to humanitarian efforts. This has been the case since its establishment.
The rise in non-oil exports is attributed to the significant improvements in infrastructure, investments, and the performance of various sectors, including petrochemicals, building materials, and food products. Government programs, initiatives, and incentives are also credited with enhancing the competitiveness of Saudi products in international markets.
The Kingdom seeks to reach an international trade system characterized by partnership, efficiency, and achievement. The Kingdom will also head the General Council of the World Trade Organization.
It represents the deep history of the Kingdom and the link between the past, present, and future. It is a chance for the new generation to learn about their history and to present a new vision of the Kingdom.
The Saudi government is investing in education with a budget that keeps pace with the requirements of growth and development. This investment aims to make Saudi education one of the top 20 educational systems in the world, in line with the Kingdom’s Vision 2030.
Rising concerns over potential supply disruptions due to new U.S. sanctions targeting the Iranian oil industry are pushing oil prices higher. These sanctions aim to intensify economic pressure on Iran and halt its oil exports, especially to major consumers like China.
Non-oil exports increased by 18.1% in December 2024 compared to December 2023. Also, the value of re-exports also increased by 23.4% during the same period.
The biggest challenge in the way of citizenship is The Heet Union and the challenge of division and fragmentation. Together, they want to work in a spirit of unity and responsibility to serve the Kingdom.
The Saudi government is trying to keep architectural heritage by creating a balance between vision and the importance of heritage. They are emphasizing the important role that architectural storytelling plays in preserving the Kingdom’s cultural heritage while embracing modernity.
The Kingdom’s historical legacy is a symbol of shared values, meanings, and goals for Saudi Arabia. The reference number 966 was another symbol.
II. Essay Questions
Answer each question in essay format with supporting evidence from the provided source material.
Discuss the Kingdom of Saudi Arabia’s role in international humanitarian efforts and diplomacy, providing specific examples from the text. How do these efforts contribute to the Kingdom’s image and standing on the global stage?
Analyze the Saudi Vision 2030 plan. What are the key objectives of this plan, and how are they being implemented across different sectors? How does it improve the Saudi brand?
Examine the economic trends and developments highlighted in the text, focusing on both the oil and non-oil sectors. What strategies are being employed to diversify the Saudi economy, and what are the early indicators of their success?
Explore the significance of Saudi Founding Day as a symbol of national identity and cultural heritage. How does the celebration of this day contribute to a sense of unity and pride among Saudi citizens?
Assess the challenges and opportunities facing Saudi Arabia in the current geopolitical landscape. How is the Kingdom navigating these challenges to achieve its strategic objectives, and what role does international cooperation play in this process?
III. Glossary of Key Terms
Vision 2030: Saudi Arabia’s strategic framework to reduce the country’s dependence on oil, diversify its economy, and develop public service sectors such as health, education, infrastructure, recreation, and tourism.
Non-Oil Exports: Goods and services exported by Saudi Arabia that do not include crude oil or petroleum products.
Humanitarian Aid: Material or logistical assistance provided for humanitarian purposes, typically in response to crises or for long-term development.
Diversification: The process of expanding an economy’s production and export base beyond a single commodity, such as oil, to reduce vulnerability to market fluctuations.
Foreign Direct Investment (FDI): An investment made by a firm or individual in one country into business interests located in another country.
Sanctions: Penalties imposed by one country or group of countries against another, typically for political reasons.
WTO (World Trade Organization): An international organization dealing with the rules of trade between nations.
Cultural Heritage: The legacy of physical artifacts and intangible attributes of a group or society inherited from past generations, maintained in the present, and bestowed for the benefit of future generations.
The Heet Union: Challenge in the way of citizenship.
OPEC+: A coalition of oil-producing countries, including OPEC (Organization of the Petroleum Exporting Countries) members and non-OPEC countries like Russia, that coordinate production policies.
Saudi Arabia: Vision 2030, Global Role, and Transformation
Okay, here’s a briefing document based on the provided sources, extracting key themes, ideas, and facts, along with relevant quotes:
Briefing Document: Analysis of “20700.pdf” Excerpts
Overall Themes:
Saudi Arabia’s Vision 2030 & National Day Celebrations: The excerpts highlight the kingdom’s focus on economic diversification, infrastructure development, and promoting national pride through events like the Foundation Day celebrations.
Economic Diversification and Growth: There’s a consistent emphasis on moving away from oil dependency, boosting non-oil exports, and improving the investment climate.
International Relations and Partnerships: The documents touch upon Saudi Arabia’s role in global humanitarian efforts, its economic cooperation with international organizations, and strengthening bilateral ties with countries like Italy.
Regional and International Issues: The document touches on the war in Ukraine and what the Saudis are doing to facilitate a peaceful solution. The Israel – Palestine conflict and Saudis commitment towards peace was also a main theme.
Cultural Preservation and Modernization: The document explores how Saudi Arabia is balancing preserving its heritage with embracing modern advancements in various sectors.
Key Ideas and Facts:
Saudi Arabia as a Trusted Government: ” This highlights Saudi Arabia’s high ranking in government trust, attributed to ongoing development efforts.
Economic Diversification Success: This indicates a positive trend in non-oil exports. The document also specifies sectors like petrochemicals, building materials, and food products as examples.
Saudi Arabia’s Global Role: The kingdom is actively involved in humanitarian aid.
Focus on Youth Empowerment: The “النطالقة” program in the Qassim region aims to empower young entrepreneurs. Quotes like “.” emphasize the importance of youth in economic development.
Digital Transformation: Efforts to develop digital systems and electronic services in the Qassim region are highlighted to improve efficiency and institutional performance.
National Identity and Heritage: The Foundation Day celebrations emphasize national pride and the connection to the kingdom’s history, aligning with Vision 2030.
Commitment to Palestine: A commitment to the plight of Palestine and a need for an end to suffering of Gazans is clearly visible.
Specific Examples and Projects:
Al-Ula Conference: The excerpt mentions the Al-Ula conference on emerging markets economies, co-organized by Saudi Arabia and the International Monetary Fund.
Qassim Region’s “النطالقة” Program: This initiative focuses on training and empowering young entrepreneurs.
King Fahd Medical City: The excerpt describes the advanced kidney dialysis unit at the King Fahd Medical City, highlighting its high standards and comprehensive services.
Italian Partnership: Italy and Saudi Arabia are looking to build closer trade and cultural ties. As indicated by the Italian ambassador”
Economic and Market Trends:
Gold Prices and Trade Wars: The document notes fluctuations in gold prices influenced by trade war concerns and tariffs imposed by the U.S.
Oil Prices and Sanctions: Rising oil prices are linked to concerns about supply disruptions due to U.S. sanctions on Iran.
Decline in Gold Smuggling in February: A note that India is expected to have reduced its gold smuggling by as much as 85%
Cautionary notes:
North West Bank facing ethnic clensing
European allies pushing to not surrender to Putin’s advances in the Ukrainian conflict
Quotes:
“إنها شراكة شاملة، تشمل الطاقة والبنية التحتية والدفاع والثقافة.” (Regarding Saudi-Italian partnership – “It’s a comprehensive partnership that includes energy, infrastructure, defense, and culture.”)
“…النفط الخام الإيرانية إلى الصفر.” (President Trump wants Iranian crude oil exports to be zero.)
“…من شأنه أن يتيح بيع مادة إي 15 على مستوى البلاد.” (Regarding a U.S. Senate bill that would allow the sale of E15 fuel nationwide.)
“…أنه هو الأساس في أي حراك تنموي وخطط طموحة لنهضة الدول وعزها ورفعتها.” (Crown Prince Mohammed bin Salman describing Saudi youth are the bedrock of development.)
“…لتسوية القضية الفلسطينية.” (Israel’s plans to dominate the land and bring the conflict to a close.)
“…أنها مصدر قلق في المنطقة والإرهاب، وأنها…” (Attitude towards Jewish people in the document)
Conclusion:
The provided excerpts paint a picture of Saudi Arabia as a nation undergoing significant economic and social transformation, actively engaging on the international stage, and striving to balance tradition with modernization. The emphasis on Vision 2030, youth empowerment, and strategic partnerships underscores the kingdom’s ambitions for the future.
Saudi Arabia: Vision 2030, Global Role, and Economic Strategy
FAQ on Themes and Ideas from Provided Sources
Here are 8 frequently asked questions (FAQs) with thorough answers, capturing the main themes and ideas present in the given sources:
1. What are the key elements of Saudi Arabia’s Vision 2030, and how are they being implemented across different sectors?
Vision 2030 emphasizes economic diversification away from oil, improving the quality of life for citizens, and enhancing Saudi Arabia’s global standing. Implementation involves attracting foreign investment, developing infrastructure (particularly in logistics), supporting non-oil sectors (like petrochemicals, manufacturing, and food industries), promoting tourism and cultural heritage, and increasing the competitiveness of Saudi products in international markets. Digital transformation and technology adoption are crucial, alongside developing human capital through education and training programs. The focus is on creating a sustainable and diversified economy while preserving cultural identity.
2. What is Saudi Arabia’s role in international humanitarian aid and diplomacy, particularly in conflict resolution?
Saudi Arabia is portrayed as a significant provider of humanitarian aid to countries and populations in need across the globe. It is a key mediator in international conflicts, as evidenced by its efforts to facilitate prisoner exchanges between Russia and Ukraine. The kingdom also plays a role in fostering economic cooperation and strategic partnerships with various nations, reflecting its growing influence on the global stage. Saudi Arabia works towards de-escalation of conflicts, stability in the region, and providing assistance to those affected by crises.
3. How does Saudi Arabia balance preserving its cultural heritage with embracing modernity and innovation?
The text highlights efforts to preserve Saudi Arabia’s cultural heritage while embracing modernity. Architectural design integrates traditional elements with modern aesthetics to create culturally rich and functional spaces. Emphasis is placed on architectural storytelling, preservation of heritage, and creation of environments that balance respect for the past with forward-looking development. Initiatives like celebrating Founding Day and supporting artistic expressions of national identity reinforce this balance.
4. What are the main economic challenges and opportunities currently facing Saudi Arabia, and what strategies are being employed to address them?
Challenges include dependence on oil revenues, fluctuations in global commodity prices (like gold and oil), and the need to diversify the economy. Opportunities lie in developing non-oil sectors, attracting foreign investment, expanding trade relationships, and leveraging its strategic location. Strategies to address challenges involve increasing competitiveness, promoting sustainable development, developing a robust logistics infrastructure, fostering innovation, and implementing financial reforms. The Kingdom is working towards sustainable economic development by empowering local entrepreneurs, supporting technological advancements, and diversifying energy sources.
5. How is Saudi Arabia investing in education and human capital development to achieve its long-term goals?
Saudi Arabia is heavily investing in education and training to create a skilled workforce aligned with Vision 2030. This includes modernizing the education system, attracting investment in private sector educational initiatives, and promoting vocational training. Initiatives like the “Notalqa” program in the Qassim region aim to equip young entrepreneurs with the skills and knowledge needed for success in the modern economy. The strategic goal is to elevate the Saudi education system to be among the top 20 globally, focusing on preparing citizens for future job market demands.
6. What is Saudi Arabia’s perspective on the Israeli-Palestinian conflict, and what role does it play in addressing the humanitarian crisis in Gaza?
The text reveals a strong condemnation of Israeli actions in the West Bank and Gaza, especially the displacement of Palestinians from their land. There is strong emphasis on the Palestinian people remaining on their land and an importance of quickly rebuilding Gaza.
7. What are the growing ties between Saudi Arabia and Italy, and how will those ties be strengthened in the future? Saudi Arabia and Italy are increasingly collaborating on trade, investment, and cultural initiatives. Italy recognizes the great potential of Saudi Arabia and views the nation as a strategic partner to improve cooperation in numerous ways, as well as an increasing trade partner that could surpass previous trade agreements. Future collaboration plans include an expansive partnership between 2025 and 2030 that focuses on political dialogue, economic cooperation, trade and investment, and cultural exchange. Focus will also be placed on art, antiquities, and the study of ancient history.
8. What challenges are facing global gold and oil markets, and what external factors influence the market in 2025?
Challenges include global trade wars, economic sanctions, and fluctuating demand. Political instability in regions like Ukraine and the Middle East impact supply chains and investor sentiment. Factors like decisions by OPEC+ regarding production cuts and potential resolutions to ongoing conflicts are crucial. Additionally, US monetary policy, interest rates, and trade policies significantly influence market dynamics.
Saudi Arabia: Global Leadership, Economic Growth, and National Identity
Saudi Arabia is committed to strengthening global peace and entrenching dialogue. The Kingdom plays a vital role in the international arena, exemplified by Riyadh becoming a diplomatic hub.
Key Aspects of Saudi Arabia Highlighted in the Source:
Global Leadership & Alliances: Saudi Arabia aims to promote global peace. Saudi Arabia is a center of international stability, fostering strong relationships with major powers while developing bilateral defense relations.
Economic Growth & Investment: The nation seeks to attract foreign investments and diversify income sources, moving beyond oil. The Kingdom is the top commercial partner to Italy in the region.
Cultural & National Identity: The Kingdom emphasizes preserving customs, values, and heritage. Celebrations such as the Founding Day on February 1727 reinforce national unity.
Technological Advancement: The Kingdom is integrating technology and AI to improve government performance and create new opportunities.
Humanitarian Efforts: The nation extends a helping hand to countries and people in need, offering aid and relief to those affected by disasters worldwide. The Kingdom seeks to enhance humanitarian responses globally.
Commitment to Education: Saudi Arabia aims to develop education within the country to be among the best.
Tourism and Development: Saudi Arabia is committed to developing tourism, and has plans for mega projects.
Real Estate Registration: The Real Estate General Authority ( عقاراتي ) calls on property owners within the area to expedite the registration of their properties through the Real Estate Registry platform.
Non-Oil Exports: Saudi Arabia’s non-oil exports increased by 18.1% in December 2024.
Government Transformation: The Saudi government is undergoing a transformation using AI.
Russia-Ukraine Conflict: Diplomacy, Global Impact, and Oil Production
The sources mention the conflict between Russia and Ukraine in the context of international relations and Saudi Arabia’s role in seeking peaceful resolutions.
Key points related to the Ukraine conflict:
Mediation and Diplomacy: Saudi Arabia is mentioned as a country where discussions on the Russia-Ukraine war have occurred, aiming to de-escalate the conflict. The Saudi Crown Prince expressed gratitude to the Russian President, Vladimir Putin, for his cordial feelings during their phone call, and for Saudi Arabia’s efforts towards Russia.
Global Impact: The conflict in Ukraine impacts the global economy and influences decisions related to oil production.
Oil Production: While not directly about the Ukraine conflict, one source notes that potential ceasefire agreements between Russia and Ukraine may alleviate some market concerns, offsetting price increases. OPEC+ is considering further delays to increasing oil production due to weak demand and high output from non-member countries.
Saudi Arabia’s Day of Foundation: History, Pride, and Celebration
The sources discuss the celebration of “Day Foundation” in Saudi Arabia, reflecting the Kingdom’s emphasis on its cultural and national identity.
Key aspects of the “Day Foundation” (يوم التأسيس) discussed in the sources:
Historical Significance: The “Day Foundation” commemorates the establishment of the first Saudi state in 1727 by Imam Muhammad bin Saud.
National Pride: It’s a national occasion to remember the Kingdom’s long history and heritage. The celebrations underscore the importance of preserving heritage and traditions, connecting the past and present while looking towards the future.
Celebrations and Events: Celebrations include various activities that reflect national values. These activities include:
Traditional Performances: Showcasing folk dances and music.
Historical Exhibitions: Featuring displays and artifacts related to the first Saudi state.
Cultural Presentations: Highlighting Saudi culture and heritage.
Marches and Parades: Featuring displays of national pride and achievements.
Educational Activities: Educational institutions, such as “teach الرياض” (تعليم الرياض), participate in celebrating the “Day Foundation”.
Community Involvement: Celebrations involve people of all ages and cultural backgrounds.
Promotion of Values: Activities and events are designed to instill values, enhance national pride, and strengthen ties to the Kingdom’s historical roots.
Economic Activity: Commemorations such as the “Day of Foundation” stimulate economic activity through festivals and tourism.
The “Day Foundation” celebrations in Saudi Arabia serve to reinforce national identity, celebrate the Kingdom’s rich history, and promote unity and pride among its citizens.
The Arabic Language: Culture, Heritage, and Innovation
The Arabic language and its significance are highlighted in the sources in several ways:
Preservation of Arabic Content: King Salman Global Academy for Arabic Language supports innovation in the Arabic language. One of its initiatives is “Business Accelerator” (مسرعة الأعمال), which aims to enrich Arabic content, develop innovative solutions, and foster creativity in the linguistic economy. This initiative aligns with Saudi Arabia’s Vision 2030.
Emphasis on Cultural Identity: The Arabic language is integral to Saudi Arabia’s cultural and national identity, and the Kingdom emphasizes preserving customs, values, and heritage.
Poetry: Classical Arabic poetry is used to celebrate the founding of Saudi Arabia, and the legacy and values of its founder, King Abdulaziz. The poetry is seen to reflect and preserve Saudi heritage and values. The source notes that this poetry is meant to instill values, enhance national pride and strengthen ties to historical roots.
Linguistic beauty: A source speaks to the beauty and eloquence of the language.
The Holy Quran: One source references the importance of the “Kabah of Revelation”, possibly the holy Quran.
Arabic Language Day: One source mentions that ” but it is unclear if the holiday is specifically about the Arabic Language.
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
Visual FoxPro provides powerful controls that you add with the Form Designer which gives you interfaces that require little or no coding. For example, having the grid control linked to one of your tables makes developing one-to-many forms easy. Just drag a table onto a form to create the grid control. For consistency with other applications you can also create tabbed dialog boxes or your own builder interfaces with the page frame control.
Creating a One-to-Many Form
Visual FoxPro makes it easy to set up forms to display records from related tables. Using the Project Manager Window and the Form Designer you can just “drag and drop” the fields you need to set up a form.
One-to-many forms display data from related tables.
Try setting up a one-to-many form using two related tables, such as the Customers and Orders tables from Testdata.dbc.
After four steps, one-to-many forms are…
…ready to run.
Specify Tables and Views for Your Form in the Data Environment You can use the data environment for your form or a report to specify the tables or views used by your form. After you have added the tables and views that have the records you want to display in your form, you can drag the fields to the Form Designer.
Create Grids by Selecting Multiple Fields You can select multiple fields and drag them to a form to create a grid object. If you select multiple fields and drag them with the right mouse button, you can choose between a grid or multiple controls. You can also click the Fields item in a table and drag it onto a form to create a grid incorporating all fields in the table. If you right-click a single field and drag it onto a form, you can create a different object class than the one that is assigned as the default object class.
Giving Your Form a Professional Look
Be creative and customize your forms with layout, colors, shapes, and graphics.
Align Controls Exactly Use the Layout toolbar to quickly line up controls and space them evenly on the form.
Change the Background Color Use the Color Palette toolbar.
Add Graphics and Pictures Use the Line, Shape, and Image buttons on the Form Controls toolbar.
Remove a Border on a Combo Box or Spinner You can use the BorderStyle Property to remove a border from the control. For example, if you are using combo box or spinner controls in a grid, you can clean up the display by removing the extra lines the border adds to the grid.
Use Current Windows Colors for Form Colors You can set an additional option on the ColorSource Property that lets you set the form colors based on the current Windows color scheme.
Setting the Properties on Controls
You can enhance your user interface with the control properties in Visual FoxPro. Using the Properties Window you can see and set the properties associated with each object in your form to determine how a form control looks and behaves.
Use Data Binding with ActiveX Controls To bind data to ActiveX controls you can use the ControlSource Property (if the control supports it) in the Properties window to specify a field or variable to which the control is bound.
Control Navigation in Page Frames By setting the tab order on your page frame you can control the order that pages are displayed. This also adds the ability to navigate to the different pages in a page frame with the right and left arrow keys.
Control Item Selection in List Box and Combo Box Controls To collect the actual value of the selected item in the control, you can set the BoundTo Property to True. To collect the item’s list index number, set the BoundTo property to False.
Select More Than 60 Items in a List Box You can now select an unlimited number of multiple items in a ListBox Control.
Create Hidden Properties and Methods You can set accessibility properties on the properties and methods you create to Public, Protected, or Hidden. To change the accessibility of properties and methods, use the Members Tab, Class Info Dialog Box.
To make your work easier, you can customize the Form Designer to match your work style and needs.
Save Changes Automatically You can set options so Visual FoxPro saves your forms automatically when you quit the Form Designer. In the Forms Tab, Options Dialog Box you can choose the option to Save Changes Before Running Form. If you select this option, you skip the confirmation dialog box, and the changes you made to the current form are saved automatically.
Change the Font in the Properties Window You can choose one of three font settings from the Properties window shortcut menu.
Use the Keyboard in the Property Window The Properties window supports keyboard navigation for scrolling through the hierarchy of objects, controls, and tab orders. Use CTRL+PGUP and CTRL+PGDN to move up and down through the list.
When you need to add controls to a form so you can navigate through the records in it, you can choose from a library of controls, drag in the controls you need, and run the form. It’s that simple.
Adding VCR Controls to a One-to-Many Form
You can use the following example to see how easy it is to streamline your work using controls from class libraries.
Store complicated control sets in a class library for reuse.
Add VCR Controls to a Form By opening the sample button class library (Buttons.vcx) supplied with Visual FoxPro, you can easily add a set of VCR-style navigation control buttons to your form. The sample libraries are in the Visual FoxPro …\Samples\Classes directory.
A class for VCR controls can be added to your toolbar.
Controls are easy to add to your form.
Set the SkipTable Property Because this is a one-to-many form, you need to specify that the next record in the main table is selected when you choose the Next button. To do this, open the Properties Window and set the SkipTable property so that it refers to the main table.
The SkipTable property adds the final functionality to your control.
Expanding Your Class Libraries
You don’t have to wait for someone else to sell you their control classes and libraries; you can make your own.
Create Your Own Classes You can create your own controls and save them in class libraries. You can start with standard Visual FoxPro classes and customize them to create your own version, or you can create your own classes.
Point to Classes in Compiled Applications You can use the SET CLASSLIB Command to point to a class included in a compiled application.
Add and Keep Classes on the Forms Control Toolbar When you add a class to the Forms Control toolbar, the class remains on the toolbar until you click the View Classes button again and select Standard.
View Detailed Information about Your Classes Using the Class Browser Window, you can view the entire hierarchy of classes and objects in a class library or form.
Create Your Own Subclasses of ActiveX Controls You can create subclasses of all the ActiveX controls shipped with Visual FoxPro.
When you create a menu, you have the option of adding a menu to the menu bar or creating a shortcut menu. The Shortcut Designer presents the familiar Menu Designer interface, but allows you to design shortcut menus rather than menu bars and menus.
After you have generated your shortcut menu, you can attach it to any control by running the menu in the control’s RightClick Event.
Creating Reports
When it’s time to print out important data, you don’t want to spend a lot of time formatting reports. That’s why Visual FoxPro provides report wizards to streamline the reporting process. With report wizards you can select the data you want from your tables and views, and present it in your choice of professional looking formats.
It’s easy to combine information from two different tables in a one-to-many report.
Using the Visual FoxPro report design features, you can:
Use the Preview Button The last screen of a report wizard has a Preview button so you can quickly see if your report is the way you like it. If not, use the Back button in the wizard and make the necessary adjustments.
Use Quick Report for Fast Results If you’re setting up your own report in the Report Designer, choose Quick Report from the Report menu to add selected fields from a table to a report.
Use Query or View Results in a Report Want to print out the results of a query? Choose the Report option in the Query Destination Dialog Box. You can send the query results to a pre-formatted report or send the query to a report wizard.
Create a One-To-Many Report The One-To-Many Report Wizard makes it easy to set up a report that shows fields from two tables joined in a one-to-many relationship. For example, try using the wizard to create a report from two related tables in Testdata.dbc.
Report Wizards retrieve records and format the report layout.
Use Other Report Wizards Try using the other report wizards. For simple one-table reports or summary reports with totals, choose Report Wizard.
Use the Report Designer If you want to customize your wizard-generated report further, just open it in the Report Designer and add the enhancements you need.
You can add value to your application by creating a Help system. Using the Help compiler included with Visual FoxPro, you can turn your document files into a graphical Help system to distribute with your applications. If you prefer to use a Visual FoxPro table to store your help information, you can create .DBF-style help. You can find a sample, Ttrade.dbf, in the …\Samples\Taztrade\Help directory. For more information about creating WinHelp and HTML Help, see Creating Graphical Help or Creating .DBF-Style Help.
See Also Overview of Visual FoxPro Features | Application Management with the Project Manager | Rapid Application Creation | Application Customization with Designers | Form Designer. | Creating Forms
Rapid Application Creation
You can develop applications rapidly with help from Visual FoxPro wizards, builders, toolbars, and designers. In addition, with the Visual FoxPro object and event model, you can create prototypes and implement applications quickly.
Getting Quick Results with Wizards and Builders
Using wizards and builders, you can have any or all of the components of your application completed in a matter of minutes. In addition, if any component you create with a wizard or builder does not fully meet your needs, you can alter the component using a designer.
Creating an Application Now
For quick results, wizards are the answer. They provide step-by-step prompts for common tasks you perform in Visual FoxPro. For example, the Table Wizard guides you through the process of creating a table, the Form Wizard creates a form, and the Web Publishing Wizard helps you create a Web page that searches your tables.
Take a look at what you can do:
Develop Instant Applications Using the Application Wizard, you can quickly create an application by using your tables and forms, or by using a sample set of application components.
Create an Internet Web Page You can create a Web page that provides Web surfers with search and retrieval access to your tables.
Add Page Frames to Forms If you choose more fields than can fit on the form, you can add a page frame to display the additional fields on additional pages.
Populate Pivot Tables through ODBC The PivotTable Wizard uses the Visual FoxPro ODBC driver.
Show Nulls in a Cross-Tab Report The Cross-Tab Wizard now supports displaying null values.
Move Your Data to a Back-End Server You can move Visual FoxPro databases, tables, and views from your system to a back-end server with the SQL Server Upsizing Wizard.
If you are in a hurry, use the table in Wizards Overview to select a wizard, and begin creating your application or component.
If you do not want to experiment with your own data and application components, use the samples provided with Visual FoxPro. You can work in the sample database Testdata.dbc, located in the …\Samples\Data directory.
Taking Shortcuts with Toolbars
Like other Microsoft applications, Visual FoxPro includes toolbars containing buttons that represent common tasks you perform or objects you use frequently. To perform a specific task or use a particular object, choose the appropriate button.
Just as wizards can help to create reports and forms, builders are visual tools that help you design controls to your specifications. Builders can save you time when you are setting up many forms or prototyping applications. All you do is start the builder and answer a series of questions. Using your answers, the builder sets properties for the control you are adding.
Add a Combo Box to Your Form Suppose you want to enhance a simple form you created by adding the ability to select field values from a list, rather than moving through all the records with VCR buttons and viewing the values in a text box. Just replace the current text box with a combo box and use a builder to set the properties.
Modify Existing Controls with a Builder If you want to change an existing control, you can select the control and use a builder to help you set the control’s properties.
For example, the Combo Box Builder is a tabbed dialog box that helps you design a combo box on a form. A combo box gives you the same view of a value as a text box control, but allows you to choose from a list like a list box control. With this builder you can set properties of a combo box. As you set each property, the control on the form changes to match the settings.
The Builder Lock button and Combo Box button
The tabs in the Combo Box Builder dialog box
Build a Grid Control To display a small spreadsheet-like view of your data, you can use a grid control. Even if you aren’t familiar with all the properties of a grid control, you can still take advantage of their functionality using a builder. The builder helps you choose the fields for your grid, select a style and layout, and establish relationships between tables bound to the grid control. As you make changes in the builder, they are reflected in the Form Designer.
Visual FoxPro offers a wide selection of builders.
Visual FoxPro is much more powerful than its predecessors. Object-oriented programming speeds up application development through features such as subclassing. The Visual FoxPro event model eliminates the need to use foundation READ or write event handlers. Optimizing your system settings and implementing Rushmore technology improves the performance of Visual FoxPro.
Harnessing the Power of Object-Oriented Programming
Using the Visual FoxPro object model, you can employ all the features of object-oriented programming including inheritance, encapsulation, polymorphism, and subclassing. For details about object-oriented programming with Visual FoxPro, see Object-Oriented Programming.
You can speed up application development by using classes. For example, you can create a basic form, toolbar, or page frame by using the form, toolbar, or page frame base class provided with Visual FoxPro.
Then you can reuse your code and forms by subclassing the classes you defined. For example, you can subclass the Form base class to create a custom class that automatically gives all the forms in your application the look and feel you want.
The Visual FoxPro class model gives you extensive control over the objects in your application. You have as much control of the appearance and behavior of objects on forms at run time as you do in the Form Designer at design time.
With Visual FoxPro you can create fully event-driven applications. You can access all standard Windows events such as mouse movements that permit dragging or dropping objects. You can control events visually through the Properties window or programmatically through the Visual FoxPro language. For more information about the event model, see Understanding the Event Model.
Testing and Debugging Immediately
Using the debug environment you can test and debug your code at the same time you design each component of your application and write the code. The Visual FoxPro language has been enhanced to include support for debugging capabilities, collection properties, checking the lock status of files and the current record, Value tips, and more. Also, the debugging tools work independently from the main application and do not interfere with the interface you are trying to test.
Test as You Design The enhanced Visual FoxPro development environment gives you more power to test your component design and code. For example, if you are designing a form, you can click the Run button to run the code. If you want to change something, just click the Design button and make your changes.
Catch Syntax Errors Early The editor now features color-coded editing: you can specify colors for syntax, normal text, variables, comments, and more in the Edit Properties Dialog Box. If you mistype a command or keyword, you’ll know right away because it’s the wrong color.
Debug with Power
You can debug and monitor your application components more easily in this version of Visual FoxPro using the Debugger Window.
View Properties of an Object In the debugger you can view the elements within a collection or array using the Watch Window to show a hierarchical display of an object’s properties.
Trace the Execution Process of Your Code In the Trace Window you can see each line of code as it executes and check the values of all variables, properties, and environment settings.
Control Execution with Breakpoints Using breakpoints you can control when execution stops using one of four types of breakpoints. You can stop at a particular line, when a certain value changes, if a condition evaluates to true, or if a condition for a certain line is true.
Set Asserts and Display Assert Messages You can use the ASSERT Command to specify conditions that verify that the code is running properly. When an error occurs, the Debug Output Output Window records the message.
Check the Current Value of a Variable To quickly check values you can place the cursor over a variable in the Trace Window to display a Value Tip.
Watch and Change Values In the Watch Window and Locals Window you can change values for properties or variables while you run the code.
Display Output from Message Requests In the Debug Output Window you can conveniently display interactive or coded information requests in a separate window from the active window or screen.
Use a Coverage Log File In the Debugger Window you can use the coverage option to log the execution information about your code such as how long the line took to execute, the line number, and more.
Visual FoxPro brings you improved performance across all these product areas:
Engine
Form/Object
OLE
Client/Server
Wizards/Builders
Language
You can also improve performance by enhancing startup speed and optimizing SET commands. For more information about optimizing your system, see Optimizing Your System.
Optimizing Applications with Rushmore Technology
You can dramatically improve the performance of queries by using Rushmore technology. Rushmore is an exclusive technology for rapidly selecting sets of records from tables. It can reduce query response times from hours or minutes to seconds. For more information about using the Rushmore technology, see Optimizing Applications.
Interaction with Other Applications
With Visual FoxPro you can share data with other applications such as Microsoft Excel and Word, use objects from other applications, and control other applications using Automation.
Sharing Data with Other Applications
You can take advantage of all the software tools on your desktop with Visual FoxPro.
Use Your FoxPro Data in Other Applications Sharing data with other applications is easy – for example, you can share Visual FoxPro data with Microsoft Excel by using the PivotTable Wizard, or with Microsoft Word by using the Mail Merge Wizard.
Display or Store Objects from Other Applications You can include objects from another application by linking or embedding them in tables or in forms. Then you can edit the objects directly, without leaving Visual FoxPro.
Editing included objects is easy in Visual FoxPro.
Importing and Exporting Data
You can import and export data between Visual FoxPro and many other applications using a variety of file formats: text, spreadsheets, and tables, to name a few. The data can be appended to or copied from existing tables easily. The Import Wizard helps you make decisions about the structure you want the data to take in Visual FoxPro.
With Visual FoxPro you have the power to fully integrate your application with other applications.
Control Other Applications You can extend the power of your application by controlling other applications programmatically. For example, you can direct Microsoft Excel to perform some calculations, instruct Microsoft Graph to chart the results, and then store the chart in a General field of a Visual FoxPro table, all from Visual FoxPro code. Or, you can add ActiveX controls that you or someone else developed.
Optimize Automation Requests You can determine how much time your system uses for requests and how long it takes for messages to appear for your user. For example, you can control how much time your system spends retrying Automation requests before displaying a “server busy” message.
You can also control the number of milliseconds that pass during user input, such as using the mouse or keyboard while an Automation request is pending, and a “busy” message appearing.
Control Visual FoxPro from Other Applications Using Visual FoxPro as an Automation server, you can create references to Visual FoxPro objects, execute Visual FoxPro commands, and run Visual FoxPro programs from other applications.
For more information on Automation, see Adding OLE.
Creating Active Documents
Active Documents are non-HTML documents viewed in a web browser such as Microsoft Internet Explorer. You can now create Active Document applications in Visual FoxPro. A Visual FoxPro Active Document is an application (.app) created from a Visual FoxPro project whose main file is set to a class based on the ActiveDoc base class.
Use the Project Manager and the Class Designer to create your Active Doc application. For more information on creating Visual FoxPro Active Documents, see Interoperability and the Internet. See ActiveDoc Object for details on its properties events and methods.
Client/Server Solution Development
You can use Visual FoxPro as a front end for developing robust client/server applications. Visual FoxPro combines the higher-level support of updatable views of server data with direct access to native server syntax using SQL pass-through. This gives you a solid foundation on which to build versatile client/server solutions. A full-featured data dictionary, local and remote views, null support, transactions, international application support, and access to any ODBC data source all contribute to the features you need for client/server development.
Increasing Client/Server Performance
You can increase the performance of your client/server application using the properties and ODBC driver provided in Visual FoxPro.
Controlling Performance with Properties
You can increase performance by using the following cursor and remote view properties:
Include or Exclude Memo Fields in Update Detection You can use the CompareMemo property to control when memo fields are used to detect update conflicts. This view and cursor property determines whether memo fields (types M or G) are included in the update WHERE clause. The default setting, True (.T.), means that memo fields are included in the WHERE clause. If you set this property to False (.F.), memo fields don’t participate in the update WHERE clause, regardless of the settings of UpdateType.
Optimistic conflict detection on Memo fields is disabled when CompareMemo is set to False (.F.). For conflict detection on memo values, CompareMemo should be set to True (.T.).
Fine Tune Record Fetching Use the FetchAsNeeded property to specify if all rows are fetched progressively, or only those within the row set determined by the FetchSize property. If you want to fetch all of the rows in the result set using the Visual FoxPro idle loop, use the default setting, False (.F.). If you want to fetch only when the user scrolls beyond the row set determined by the FetchSize property, set FetchAsNeeded to True (.T.) to fetch the next row set.
Speed Up Re-query Operations on Parameterized Views Using the Prepared property, you can set whether the query for the view is prepared before it is executed. If you set this property to True (.T.), Visual FoxPro sends a request to the ODBC driver to prepare or compile the SQL query that defines the view. If the ODBC driver for your back-end data source supports the use of prepared statements, subsequent re-queries on the open view are executed faster.
Using ODBC for Quick Access to Visual FoxPro Data
The Visual FoxPro ODBC Driver provides quick access to Visual FoxPro data. End users and developers of many applications, including Microsoft Access, Microsoft Excel, Visual C++, and Visual Basic, can use this driver to retrieve, manipulate and update Visual FoxPro data. For more information about the Visual FoxPro ODBC Driver, see the Drvvfp.hlp file.
Defining Rules with the Data Dictionary
Visual FoxPro databases (.dbc files) provide a data dictionary that allows you to add rules, views, triggers, persistent relationships, and connections to every table in a database.
Within a database you can define:
Field-level or record-level rules that Visual FoxPro enforces wherever the table is used in an application.
Primary and candidate index keys.
Local and remote views.
Triggers.
Persistent relationships between database tables.
Connections to remote data sources.
Stored procedures.
Default values on fields.
Long table and field names.
In addition, you can enforce referential integrity for every persistent relationship by using the Referential Integrity Builder to define rules for inserts, updates, and deletes.
Visual FoxPro also supports null values in tables, greatly improving compatibility and connectivity with other data sources such as Microsoft Access, Visual Basic, and SQL-based servers. For details about null values, search for “null” and “null values”.
Each Visual FoxPro database is completely user-extensible, with access through language enhancements and the visual designers. For more information about databases and data dictionaries, see Creating Databases.
View Local, Remote, and Offline Data You can design and test a client/server application on your local computer using data from remote, local, or multiple-table heterogeneous views. Local views use tables on your local computer rather than tables on a remote server, and multiple table views use related data from separate tables. You can create parameterized views to minimize the amount of data you download from the server, take the data on the road, or update remote data from your Visual FoxPro application. For more information about views see Creating Views.
Manage Shared Access with Transactions You can design your application to provide shared access to data. Shared access involves sharing data among users and restricting access when necessary. Transactions and buffering — pessimistic or optimistic, record-level or table-level — mean less programming for you. Built-in batch processing and detailed control over handling update conflicts simplifies updating data in a multiuser environment. For details about designing your application for shared access, see Programming for Shared Access.
Develop International Applications Visual FoxPro provides several areas of support for developing international applications. For example, Visual FoxPro supports several code pages. The code pages for Greek and Russian are supported on MS-DOS, Microsoft Windows, and Macintosh platforms. Visual FoxPro also supports double-byte character sets for languages such as Japanese, Korean, Traditional Chinese, and Simplified Chinese. In addition, Visual FoxPro supports collation sequences for languages such as Japanese, German, Traditional Chinese, and Icelandic. For more information about international applications, see Developing International Applications.
Implement a Client/Server Application In addition to using views for client/server development, you can send any native server syntax you want directly to a server with Visual FoxPro SQL pass-through functions. These functions permit additional server access and control beyond the capability of views. For details about SQL pass-through see Implementing a Client/Server Application.
After designing your application locally, you can upsize and implement it against a back-end data source. Upsizing applies the benefits of client/server architecture to the local application and allows you to create a remote server database with the same table structure and data as the original Visual FoxPro tables. When you upsize, you choose which tables move to the server and which remain locally for more immediate access. For details about upsizing see Upsizing Visual FoxPro Databases.
Visual FoxPro and XML
Extensible Markup Language (XML) is the standard language for describing and delivering data on the Web, just as Hypertext Markup Language (HTML) is the standard language for creating and displaying Web pages. XML uses tags and attributes to delimit pieces of data, and leaves the interpretation of the data completely to the application that reads it. For more details, see XML Functions.
To make it possible for you to more easily implement data exchange via XML, Visual FoxPro provides new functions and functionality in the following functions:
CURSORTOXML( ) Converts a Visual FoxPro cursor into XML.
XMLUPDATEGRAM( ) Creates an XML UpdateGram from changes made to a buffered table or cursor.
XMLTOCURSOR( ) Converts XML data to a Visual FoxPro cursor or table.
Miscellaneous XBase Features
Visual FoxPro includes a number of new and improved XBase features, those written in the Visual FoxPro language itself. These include new tools such as the Task List Manager, Object Browser, IntelliSense Manager, Accessibility Browser, Automated Test Harness and Web Services wizard. These are described in more detail in other What’s New topics.
In addition to the above-mentioned features, Visual FoxPro contains a wealth of other XBase improvements.
New Foundation Classes have been added for use with Microsoft Agent, Regular Expressions, Cryptography, Enhanced File Open dialog boxes, Windows 2000 Logo information, and Web Services.
The SQL Server Upsizing wizard contains a number of new improvements.
New Solution samples have been added to better illustrate some of the new Visual FoxPro features and foundation classes.
A new set of COM+ Service samples show how you can use Visual FoxPro servers with COM+ Services such as Transactions, Queued Components, COM+ Events and Compensating Resource Managers. Many of these samples use new Visual FoxPro server enhancements.
GENMENU has been updated to support new image support for menus. A new directive (#IMAGEPATHS) has been added to control if full paths are generated for menu images.
Visual FoxPro OLE DB Provider
The Visual FoxPro OLE DB Provider makes it possible for application developers to access Visual FoxPro data from other languages and applications, as well as from Visual FoxPro when appropriate. The Visual FoxPro provider exposes OLE DB interfaces to consumers wanting access to data on one or more Visual FoxPro databases. You can use it as part of an OLE DB consumer for Visual FoxPro databases.
The Visual FoxPro OLE DB Provider supports new Visual FoxPro features, such as database container (DBC) events, access to stored procedures, and the ability to create, modify, and delete functions and procedures in the DBC stored procedure module.
In the Visual FoxPro OLE DB Provider, you will find an improved threading model for better scalability and all the functionality of the Visual FoxPro ODBC driver of earlier versions of FoxPro.
Behavior Changes since the Previous Version
This section describes behavioral characteristics of Visual FoxPro that differ from those of the previous version. It is possible that these changes affect existing code.
_SCREEN and _VFP coordinate properties (Top, Left, Height, Width) have been changed to better distinguish between the two windows they represent. The _VFP coordinates represent the entire Visual FoxPro application window (including menu and status bars). The _SCREEN coordinates represent the desktop area (for example, the window to which ? output is directed).
For performance reasons, the CreateObject( ) function no longer adds a sequential number to the value for a dynamically created Name property. This applies to class definitions in .PRG files that do not have an explicitly set Name property and base classes.
Because of new support for IntelliSense and COM server typing (for example, LOCAL cName AS string), the use of a variables list separated by spaces only (for example, LOCAL x y z) is no longer allowed. You must separate variables with commas (for example, LOCAL x, y, z).
The Session class now hides intrinsic properties, methods, and events in the generated type library for an OLEPUBLIC subclass. Additionally, when using a private data session with a Session object, the default setting for SET TALK, SET EXCLUSIVE, SET SAFETY is now OFF.
The VERSION( ) format has changed. The Build number is now the last set of digits. This also might affect usage of the AGETFILEVERSION() function in your code.
Some of the values of HOME([n]) have changed. Some of these changes only apply to an installation of Visual Studio. The location of the Samples and Graphics folders is now under the Visual FoxPro root directory.
The new default location to save files has been changed for compliance with Windows 2000 Logo guidelines. You can view (and change) this location from the Options dialog box (File Locations tab).
The format for menus (MNX file) has changed to include new Picture support.
The format for a database (DBC) file will be altered if DBC Events is enabled. This will render the DBC incompatible with prior versions of Visual FoxPro and the ODBC driver. You can restore backward compatibility by disabling DBC events for the DBC. The Visual FoxPro OLE DB provider does support DBC Events.
The Command window contents are now persisted between sessions of Visual FoxPro. The contents are stored in a file named _command.prg.
The resource file (for example, FOXUSER) is now opened shared, so you can run multiple instances of Visual FoxPro using the same FOXUSER file. As in prior versions, you can set the resource file from the Options dialog box.
The Visual FoxPro run-time libraries (for example, VFP7T.DLL) are no longer installed in the WinSys directory. Additionally, resource files for other languages are now installed with the English product.
The Properties window stays open when it is set as Dockable, even if the current form/class designer is closed.
Old FoxBASE+ support for FOXGRAPH, FOXVIEW, FOXGEN, FOXCODE, CENTRAL, and ASSIST is no longer supported.
The Windows Explorer shell open functionality for known Visual FoxPro file types now launches a new instance of Visual FoxPro. Additionally, Program and Query files support both Open and Run support. The default for Program files is now Open instead of Run as in previous versions.
The Class/Form Designer surface grid now displays in actual grid coordinates instead of the behavior of previous versions of Visual FoxPro, which was to display in 2x actual setting.
Grid column headers now allow for display of keyboard shortcuts. This is for display only, so developers must write code to handle the shortcut action.
Search path for #INCLUDES has been extended for PRGs, SCXs and VCXs.
The format of the event-tracking log generated using the SET EVENTTRACKING command now includes a TimeStamp column.
The _DBLCLICK system variable no longer controls incremental search duration for controls such as list boxes. Now this is handled by a new system variable called _INCSEEK.
A startup application (for example, VFP7Strt.app) no longer ships with Visual FoxPro.
The nStartPos parameter for ASCAN() will only produce an error if a value of 0 is passed. Values passed which are larger than the length of the array will return 0.
In previous versions, CREATE TABLE ... NAME LongTableName substituted spaces with underscores (“_”) for the LongTableName when called programmatically. This would not occur when specified in the Table Designer. In this version, spaces are now preserved, which is now consistent with the behavior of the Table Designer.
Feature Changes since the Previous Version of Visual FoxPro
The following features from the previous version of Visual FoxPro have been removed from the product:
The Spell Checker is no longer included with the product.
The Setup wizard is no longer included with the product. A Microsoft Installer based deployment tool will be available. For details, see Distributing Applications.
The Graph runtime is no longer included, because it was primarily for distribution with the Setup wizard.
The Run ActiveDoc menu item is no longer in the product, but the program is still available and can be called from the Do menu.
Several of the MSDN menu items have been removed from the Help menu. Online documentation for the product is available in a stand-alone help file as well as in the MSDN Library. Additionally, the Microsoft on the Web submenu has been replaced with a single Visual FoxPro on the Web menu item.
The Calendar, Outline, and FoxHWnd controls no longer ship with Visual FoxPro.
The Visual FoxPro ODBC Driver no longer ships with Visual FoxPro. This is available from the Visual FoxPro Web site (http://msdn.microsoft.com/vfoxpro/). The Visual FoxPro OLE DB Provider is the preferred solution for clients accessing Visual FoxPro data remotely.
Classes and Objects: The Building Blocks of Applications
Classes and objects are closely related, but they are not the same. A class contains information about how an object should look and behave. A class is the blueprint or schematic of an object. The electrical schematic and design layout of a telephone, for example, would approximate a class. The object, or an instance of the class, would be a telephone.
Objects Have Properties
An object has certain properties, or attributes. For example, a phone is a certain color and size. When you put a phone in your office, it has a certain position on your desk. The receiver can be on or off the hook.
Objects you create in Visual FoxPro also have properties that are determined by the class the object is based on. These properties can be set at design time or at run time.
For example, some of the properties that a check box can have are listed in the following table:
Property
Description
Caption
The descriptive text beside the check box.
Enabled
Specifies whether a user can choose the check box.
ForeColor
The color of the caption text.
Left
The position of the left side of the check box.
MousePointer
How the mouse pointer looks when over the check box.
Top
The position of the top of the check box.
Visible
Specifies whether the check box is visible.
Objects Have Associated Events and Methods
Each object recognizes and can respond to certain actions called events. An event is a specific and predetermined activity, initiated by either a user or the system. Events, in most cases, are generated by user interaction. For example, with a phone, an event is triggered when a user takes the receiver off the hook. Events are also triggered when the user presses the buttons to make a call.
In Visual FoxPro, user actions that trigger events include clicks, mouse moves, and key presses. Initializing an object and encountering a line of code that causes an error are system-initiated events.
Methods are procedures that are associated with an object. Methods are different from normal Visual FoxPro procedures: methods are inextricably bound with an object and are called differently than normal Visual FoxPro procedures are called.
Events can have methods associated with them. For example, if you write method code for the Click event, that code is executed when the Click event occurs. Methods can also exist independently of any events. These methods must be explicitly called in code.
The event set, while extensive, is fixed. You can’t create new events. The method set, however, is infinitely extendible.
The following table lists some of the events associated with a check box:
The focus is set to the check box just as though the user had pressed the TAB key until the check box was selected.
Classes in Visual FoxPro
All of the properties, events, and methods for an object are specified in the class definition. In addition, classes have the following characteristics that make them especially useful for creating reusable, easily maintained code:
Encapsulation
Subclasses
Inheritance
Hiding Unnecessary Complexity
When you include a phone in your office, you probably don’t care how the phone internally receives a call, initiates or terminates connections to electronic switchboards, or translates key presses into electronic signals. All you need to know is that you can lift the receiver, dial the appropriate numbers, and talk to the person you want to talk to. The complexity of making that connection is hidden. The benefit of being able to ignore the inner details of an object so you can focus on the aspects of the object you need to use is called abstraction.
Encapsulation, which involves packaging method and property code together in an object, contributes to abstraction. For example, the properties that determine the items in a list box and the code that executes when you choose an item in the list can be encapsulated in a single control that you add to a form.
Leveraging the Power of Existing Classes
A subclass can have all the functionality of an existing class, plus any additional controls or functionality you want to give it. If your class is a basic telephone, you can have subclasses that have all the functionality of the original telephone and any specialized features you want to give them.
Subclassing is one way to decrease the amount of code you have to write. Start with the definition of an object that is close to what you want, and customize it.
Streamlining Code Maintenance
With inheritance, if you make a change to a class, that change is reflected in all subclasses based on the class. This automatic update saves you time and effort. For example, if a phone manufacturer wanted to change from dial to push-button style phones, it would save a lot of work to be able to make the change to the master schematic and have all previously manufactured phones based on that master schematic automatically inherit this new feature, rather than having to add the new feature to all the existing phones individually.
Inheritance doesn’t work with hardware, but you do have this capability in software. If you discover a bug in your class, instead of having to go to each subclass and change the code, you fix it once in the class and the change propagates throughout all subclasses of the class.
Containers and Non-Containers
The two primary types of Visual FoxPro classes, and by extension Visual FoxPro objects, are container classes and control classes.
Container Classes
Containers can contain other objects and allow access to the objects contained within them. For example, if you create a container class that consists of two list boxes and two command buttons, and then add an object based on this class to a form, each individual object can be manipulated at run time and design time. You can easily change the positions of the list boxes or the captions of the command buttons. You can also add objects to the control at design time; for example, you can add labels to identify the list boxes.
The following table lists what each container class can contain:
Container
Can contain
Command button groups
Command buttons
Container
Any controls
Control
Any controls
Custom
Any controls, page frame, container, custom
Form sets
Forms, toolbars
Forms
Page frames, any controls, containers, custom
Grid columns
Headers and any objects except form sets, forms, toolbars, timers, and other columns
Grids
Grid columns
Option button groups
Option buttons
Page frames
Pages
Pages
Any controls, containers, custom
Project
Files, servers
Toolbars
Any controls, page frame, container
Control Classes
Control classes are more completely encapsulated than container classes are, but can be less flexible for that reason. Control classes do not have an AddObject method.
Preparation for Class Creation
You want to be able to use classes in many different contexts. Smart planning will enable you to most effectively decide what classes to design and what functionality to include in the class.
Deciding When to Create Classes
You could create a class for every control and every form you might ever use, but this isn’t the most effective way to design your applications. You’ll likely end up with multiple classes that do much the same thing but must be maintained separately.
Encapsulate Generic Functionality
You can create a control class for generic functionality. For example, command buttons that allow a user to move the record pointer in a table, a button to close a form, and a help button, can all be saved as classes and added to forms any time you want the forms to have this functionality.
You can expose properties and methods on a class so that the user can integrate them into the particular data environment of a form or form set.
Provide a Consistent Application Look and Feel
You can create form set, form, and control classes with a distinctive appearance so that all the components of your application have the same look. For example, you could add graphics and specific color patterns to a form class and use that as a template for all forms you create. You could create a text box class with a distinctive appearance, such as a shadowed effect, and use this class throughout your application any time you want to add a text box.
Deciding What Type of Class to Create
Visual FoxPro allows you to create several different kinds of classes, each with its own characteristics. You specify the type of class you want to create in the New Class dialog box or in the AS clause in the CREATE CLASS command.
The Visual FoxPro Base Classes
You can create subclasses of most of the Visual FoxPro base classes in the Class Designer.
The class that the current class was derived from. If the class was derived directly from a Visual FoxPro base class, the ParentClass property is the same as the BaseClass property.
Extending the Visual FoxPro Base Classes
You can subclass these classes to set your own default control properties. For example, if you want the default names of controls you add to forms in your applications to automatically reflect your naming conventions, you can create classes based on the Visual FoxPro base classes to do this. You can create form classes with a customized look or behavior to serve as templates for all the forms you create.
You could also subclass the Visual FoxPro base classes to create controls with encapsulated functionality. If you want a button to release forms when the button is clicked, you can create a class based on the Visual FoxPro command button class, set the caption property to “Quit” and include the following command in the Click event:
THISFORM.Release
You can add this new button to any form in your application.
Creating Controls with Multiple Components
Your subclasses aren’t limited to single base classes. You can add multiple controls into a single container class definition. Many of the classes in the Visual FoxPro sample class library fall into this category.
Creating Non-Visual Classes
A class based on the Visual FoxPro custom class doesn’t have a run-time visual element. You can create methods and properties for your custom class using the Class Designer environment. For example, you could create a custom class named StrMethods and include a number of methods to manipulate character strings. You could add this class to a form with an edit box and call the methods as needed. If you had a method called WordCount, you could call it when needed:
Non-visual classes (like the custom control and the timer control) have a visual representation only at design time in the Form Designer. Set the picture property of the custom class to the .bmp file you want displayed in the Form Designer when the custom class is added to a form.
Operating the Class Designer
When you specify what class your new class is based on and the library to store the class in, the Class Designer opens.
The Class Designer provides the same interface that the Form Designer does, allowing you to see and edit the properties of your class in the Properties window. Code editing windows allow you to write code to be executed when events occur or methods are called.
Adding Objects to a Control or Container Class
If you base the new class on the control or container class, you can add controls to it the same way you add controls in the Form Designer: choose the control button on the Form Controls toolbar and drag to size in the Class Designer.
No matter what type of class you base the new class on, you can set properties and write method code. You can also create new properties and methods for the class.
IF you press and hold the CTRL key while dragging objects from the toolbar to a form class, you disengage the default snap-to-grid behavior.
Adding Properties and Methods to a Class
You can add as many new properties and methods to the new class as you want. Properties hold values; methods hold procedural code to be run when you call the method.
Creating New Properties and Methods
When you create new properties and methods for classes, the properties and methods are scoped to the class, not to individual components in the class.
To add a new property to a class
From the Class menu, choose New Property.
In the New Property dialog box, type the name of the property.
Specify the visibility: Public, Protected, or Hidden. A Public property can be accessed anywhere in your application. Protected and Hidden properties and methods are discussed in Protecting and Hiding Class Members.
Choose Add. You can also include a description of the property that will be displayed at the bottom of the Properties window in the Class Designer and in the Form Designer when the control is added to a form. Caution When you add a property to a class that can be set by a user of the class, the user could enter an invalid setting for your property that could cause run-time errors. You need to explicitly document the valid settings for the property. If your property can be set to 0, 1, or 2, for example, say so in the Description box of the New Property dialog box. You might also want to verify the value of the property in code that references it.
To create an array property
In the Name box of the New Property dialog box, specify the name, size, and dimensions of the array. For example, to create an array property named myarray with ten rows and two columns, type the following in the Name box: myarray[10,2]
The array property is read-only at design time and is displayed in the Properties window in italics. The array property can be managed and redimensioned at run time. For an example of using an array property, see Managing Multiple Instances of a Form, Creating Forms.
To add a new method to a class
From the Class menu, choose New Method.
In the New Method dialog box, type the name of the method.
Specify the visibility: Public, Protected, or Hidden.
Select the Access check box to create an Access method, select the Assign check box to create an Assign method, or select both check boxes to create Access and Assign methods.
Access and Assign methods let you execute code when the value of a property is queried or when you attempt to change the property’s value.
The code in an Access method is executed when the value of a property is queried, typically by using the property in an object reference, storing the value of the property to a variable, or displaying the value of property with a question mark (?).
The code in an Assign method is executed when you attempt to change the value of a property, typically by using the STORE or = command to assign a new value to the property.
You can also include a description of the method.
Creating Classes
You can create new classes in the Class Designer and you can see how each object will appear to the user as you design it.
To create a new class
In the Project Manager, select the Classes tab and choose New. -or-
From the File menu, choose New, select Class, and choose New File. -or-
The New Class dialog box lets you specify what to call the new class, the class to base the new class on, and the library to store it in.
Modifying a Class Definition
Once you have created a class, you can modify it. Changes made to a class affect all the subclasses and all the objects based on this class. You can add an enhancement to a class or fix a bug in the class, and all the subclasses and objects based on the class will inherit the change.
To modify a class in the Project Manager
Select the class you want to modify.
Choose Modify. The Class Designer opens.
You can also modify a visual class definition with the MODIFY CLASS command.
Caution Don’t change the Name property of a class if the class is already being used in any other application components. Otherwise, Visual FoxPro will not be able to locate the class when needed.
Subclassing a Class Definition
You can create a subclass of a user-defined class in one of two ways.
To create a subclass of a user-defined class
In the Project Manager New Class dialog box, click the dialog button to the right of the Based On box.
In the Open dialog box, choose the class you want to base the new class on. -or-
Use the CREATE CLASS command. For example, to base a new class, x, on parentclass in Mylibrary.vcx, use this code: CREATE CLASS x OF y AS parentclass ; FROM mylibrary
Class Member Protection and Hiding
Properties and methods in a class definition are Public by default: code in other classes or procedures can set the properties or call the methods. Properties and methods that you designate as Protected can be accessed only by other methods in the class definition or in subclasses of the class. Properties and methods designated as Hidden can be accessed only by other members in the class definition. Subclasses of the class cannot “see” or reference hidden members.
To ensure correct functioning in some classes, you need to prevent users from programmatically changing the properties or calling the method from outside the class.
The following example illustrates using protected properties and methods in a class.
The stopwatch class included in Samples.vcx, in the Visual FoxPro …\Samples\Classes directory, includes a timer and five labels to display the elapsed time:
This class also has three protected properties, nSec, nMin, and nHour, and one protected method, UpdateDisplay. The other three custom methods in the class, Start, Stop, and Reset, are not protected.
Tip Choose Class Info on the Class menu to see the visibility of all properties and methods of a class.
The protected properties are used in internal calculations in the UpdateDisplay method and the Timer event. The UpdateDisplay method sets the captions of the labels to reflect the elapsed time.
The user cannot directly set these properties or call this method, but code in the Reset method can.
Specifying the Default Value for a Property
When you create a new property, the default setting is false (.F.). To specify a different default setting for a property, use the Properties window. In the Other tab, click on your property and set it to the desired value. This will be the initial property setting when the class is added to a form or form set.
You can also set any of the base class properties in the Class Designer. When an object based on the class is added to the form, the object reflects your property settings rather than the Visual FoxPro base class property settings.
Tip If you want to make the default setting of a property an empty string, select the setting in the Property Editing box and press the BACKSPACE key.
Specifying Design-Time Appearance for a Class
You can specify the toolbar icon and the container icon for your class in the Class Info dialog box.
To set a toolbar icon for a class
In the Class Designer, choose Class Info from the Class menu.
In the Class Info dialog box, type the name and path of the .bmp file in the Toolbar icon box. Tip The bitmap (.bmp file) for the toolbar icon is 15 by 16 pixels. If the picture is larger or smaller, it is sized to 15 by 16 pixels and might not look the way you want it to.
The toolbar icon you specify is displayed in the Form Controls toolbar when you populate the toolbar with the classes in your class library.
You can also specify the icon to be displayed for the class in the Project Manager and Class Browser by setting the container icon.
To set a container icon for a class
In the Class Designer, choose Class Info from the Class menu.
In the Container icon box, type the name and path of the .bmp file to be displayed on the button in the Form Controls toolbar.
Creating, Copying, and Removing Class Library Files
Every visually designed class is stored in a class library with a .vcx file extension.
Creating a Class Library
You can create a class library in one of three ways.
To create a class library
When you create a class, specify a new class library file in the Store In box of the New Class dialog box. -or-
Use the CREATE CLASS command, specifying the name of the new class library. For example, the following statement creates a new class named myclass and a new class library named new_lib: CREATE CLASS myclass OF new_lib AS CUSTOM -or-
Use the CREATE CLASSLIB command. For example, type the following command in the Command window to create a class library named new_lib: CREATE CLASSLIB new_lib
Copying and Removing Class Library Classes
Once you add a class library to a project, you can easily copy classes from one library to another or simply remove classes from libraries.
To copy a class from one library to another
Make sure both libraries are in a project (not necessarily the same project).
Click the plus sign (+) to the left of the class library that the class is now in.
Drag the class from the original library and drop it in the new library. Tip For convenience and speed, you might want to keep a class and all the subclasses based on it in one class library. If you have a class that contains elements from many different class libraries, these libraries must all be open, so it will take a little longer to initially load your class at run time and at design time.
To remove a class from a library
Select the class in the Project Manager and choose Remove. -or-
To change the name of a class in a class library, use the RENAME CLASS command. Remember, however, that when you change the name of a class, forms that contain the class and subclasses in other .vcx files continue to reference the old name and will no longer function correctly.
Visual FoxPro includes a Class Browser to facilitate using and managing classes and class libraries. For more information, see Class Browser.
Adding Classes to Forms
You can drag a class from the Project Manager to the Form Designer or to the Class Designer. You can also register your classes so that they can be displayed directly on the Form Controls toolbar in the Class Designer or Form Designer and added to containers the same way the standard controls are added.
To register a class library
From the Tools menu, choose Options.
In the Options dialog box choose the Controls tab.
Select Visual Class Libraries and choose Add.
In the Open dialog box, choose a class library to add to the registry and choose Open.
Choose Set as Default if you want the class library to be available in the Form Controls toolbar in future sessions of Visual FoxPro.
You can also add your class library to the Form Controls toolbar by choosing Add in the submenu of the View Classes button. To make these classes available in the Form Controls toolbar in future sessions of Visual FoxPro, you still need to set the default in the Options dialog box.
Default Property Setting Override
When you add objects based on a user-defined class to a form, you can change the settings of all the properties of the class that are not protected, overriding the default settings. If you change the class properties in the Class Designer later, the settings in the object on the form are not affected. If you have not changed a property setting in the form and you change the property setting in the class, the change will take effect in the object as well.
For example, a user could add an object based on your class to a form and change the BackColor property from white to red. If you change the BackColor property of the class to green, the object on the user’s form will still have a background color of red. If, on the other hand, the user did not change the BackColor property of the object and you changed the background color of the class to green, the BackColor property of the object on the form would inherit the change and also be green.
Calling Parent Class Method Code
An object or class based on another class automatically inherits the functionality of the original. However, you can easily override the inherited method code. For example, you can write new code for the Click event of a class after you subclass it or after you add an object based on the class to a container. In both cases, the new code is executed at run time; the original code is not executed.
More frequently, however, you want to add functionality to the new class or object while keeping the original functionality. In fact, one of the key decisions you have to make in object-oriented programming is what functionality to include at the class level, at the subclass level, and at the object level. You can optimize your class design by using the DODEFAULT( ) function or scope resolution operator (::) to add code at different levels in the class or container hierarchy.
Adding Functionality to Subclasses
You can call the parent class code from a subclass by using the DODEFAULT( ) function.
For example, cmdOK is a command button class stored in Buttons.vcx, located in the Visual FoxPro …\Samples\Classes directory. The code associated with the Click event of cmdOk releases the form the button is on. CmdCancel is a subclass of cmdOk in the same class library. To add functionality to cmdCancel to discard changes, for example, you could add the following code to the Click event:
IF USED( ) AND CURSORGETPROP("Buffering") != 1
TABLEREVERT(.T.)
ENDIF
DODEFAULT( )
Because changes are written to a buffered table by default when the table is closed, you don’t need to add TABLEUPDATE( ) code to cmdOk. The additional code in cmdCancel reverts changes to the table before calling the code in cmdOk, the ParentClass, to release the form.
Writing Class Definitions Programmatically
You can define classes visually in the Class Designer and the Form Designer or programmatically in .PRG files. This section describes how to write class definitions. For more information about forms, see Creating Forms.
Programming in Visual FoxPro Microsoft® Visual FoxPro® is a powerful interactive data management tool, but you also can access the full power of Visual FoxPro by creating applications. Understanding object-oriented programming techniques and the event-driven model can maximize your programming productivity. Application Development As you develop an application, organize its pieces with the Project Manager, an integrated way to build and test your application as you go. Object-Oriented Programming With object-oriented programming, you can create self-contained application components that respond to user actions and to the system and which can be easily maintained and reused. Understanding the Event Model The event model defines when and how user and system interactions occur.
Programmatic Class Definitions
In a program file, you can have program code prior to the class definitions, but not after the class definitions, in the same way that program code cannot come after procedures in a program. The basic shell for class creation has this syntax:
DEFINE CLASS ClassName1 AS ParentClass [OLEPUBLIC]
[[PROTECTED | HIDDEN PropertyName1, PropertyName2 ...]
[Object.]PropertyName = eExpression ...]
[ADD OBJECT [PROTECTED] ObjectName AS ClassName2 [NOINIT]
[WITH cPropertylist]]...
[[PROTECTED | HIDDEN] FUNCTION | PROCEDURE Name[_ACCESS | _ASSIGN]
[NODEFAULT]
cStatements
[ENDFUNC | ENDPROC]]...
ENDDEFINE
Protection and Hiding of Class Members
You can protect or hide properties and methods in a class definition with the PROTECTED and HIDDEN keywords of the DEFINE CLASS command.
For example, if you create a class to hold employee information, and you don’t want users to be able to change the hire date, you can protect the HireDate property. If users need to find out when an employee was hired, you can include a method to return the hire date.
When you have saved a visual class, you can create an object based on it with the CREATEOBJECT( ) function. The following example demonstrates running a form saved as a class definition in the class library file Forms.vcx:
Creating and Showing a Form Object Whose Class Was Designed in the Form Designer
Set the class library to the .vcx file that the form definition was saved in. The ADDITIVE keyword prevents this command from closing any other class libraries that happen to be open.
This code assumes that the name of the form class saved in the class library is TestForm.
frmTest.Show
Display the form.
Addition of Objects to a Container Class
You can use the ADD OBJECT clause in the DEFINE CLASS command or the AddObject method to add objects to a container.
For example, the following class definition is based on a form. The ADD OBJECT command adds two command buttons to the form:
DEFINE CLASS myform AS FORM
ADD OBJECT cmdOK AS COMMANDBUTTON
ADD OBJECT PROTECTED cmdCancel AS COMMANDBUTTON
ENDDEFINE
Use the AddObject method to add objects to a container after the container object has been created. For example, the following lines of code create a form object and add two command buttons to it:
You can also use the AddObject method in the method code of a class. For example, the following class definition uses AddObject in the code associated with the Init event to add a control to a grid column.
DEFINE CLASS mygrid AS GRID
ColumnCount = 3
PROCEDURE Init
THIS.Column2.AddObject("cboClient", "COMBOBOX")
THIS.Column2.CurrentControl = "cboClient"
ENDPROC
ENDDEFINE
Adding and Creating Classes in Method Code
You can programmatically add objects to a container with the AddObject method. You can also create objects with the CREATEOBJECT( ) function in the Load, Init, or any other method of the class.
When you add an object with the AddObject method, the object becomes a member of the container. The Parent property of the added object refers to the container. When an object based on the container or control class is released from memory, the added object is also released.
When you create an object with the CREATEOBJECT( ) function, the object is scoped to a property of the class or a variable in the method that calls this function. The parent property of the object is undefined.
Method and Event Code Guidelines
In addition to writing code for the methods and events of an object, you can extend the set of methods in subclasses of Visual FoxPro base classes. Here are the rules for writing event code and methods:
The event set for the Visual FoxPro base classes is fixed and cannot be extended.
Every class recognizes a set of fixed default events, the minimum set of which includes Init, Destroy, and Error events.
When you create a method in a class definition with the same name as an event that the class can recognize, the code in the method is executed when the event occurs.
You can add methods to your classes by creating a procedure or function within the class definition.
You can create Access and Assign Methods for your classes by creating a procedure or function with the same name as a class property and _ACCESS or _ASSIGN appended to the procedure or function name.
Calling Event Code up the Class Hierarchy
When you create a class, the class automatically inherits all the properties, methods, and events of the parent class. If code is written for an event in the parent class, that code is executed when the event occurs with respect to an object based on the subclass. You can, however, overwrite the parent class code by writing code for the event in the subclass.
To explicitly call the event code in a parent class when the subclass has code written for the same event, use the DODEFAULT( ) function.
For example, you could have a class named cmdBottom based on the command button base class that has the following code in the Click event:
GO BOTTOM
THISFORM.Refresh
When you add an object based on this class to a form, named, for example, cmdBottom1, you might decide that you also want to display a message for the user so that he or she knows that the record pointer is at the bottom of the table. You could add the following code to the Click event of the object to display the message:
WAIT WINDOW "At the Bottom of the Table" TIMEOUT 1
When you run the form, however, the message is displayed, but the record pointer doesn’t move because the code in the Click event of the parent class is never executed. To make sure the code in the Click event of the parent class is also executed, include the following lines of code in the Click event procedure of the object:
DODEFAULT( )
WAIT WINDOW "At the Bottom of the Table" TIMEOUT 1
Note You can use the ACLASS( ) function to determine all the classes in an object’s class hierarchy.
Preventing Base Class Code from Executing
Sometimes you’ll want to prevent the base class default behavior from taking place in an event or method. You can do this by including the NODEFAULT keyword in the method code you write. For example, the following program uses the NODEFAULT keyword in the KeyPress event of a text box to prevent the typed characters from being displayed in the text box:
frmKeyExample = CREATEOBJECT("test")
frmKeyExample.Show
READ EVENTS
DEFINE CLASS test AS FORM
ADD OBJECT text1 AS TEXTBOX
PROCEDURE text1.KeyPress
PARAMETERS nKeyCode, nShiftAltCtrl
NODEFAULT
IF BETWEEN(nKeyCode, 65, 122) && between 'A' and 'z'
This.Value = ALLTRIM(This.Value) + "*"
ACTIVATE SCREEN && send output to main Visual FoxPro window
?? CHR(nKeyCode)
ENDIF
ENDPROC
PROCEDURE Destroy
CLEAR EVENTS
ENDPROC
ENDDEFINE
Creating a Set of Table Navigation Buttons
A common feature of many applications is a series of navigation buttons that allow users to move through a table. These typically include buttons to move the record pointer to the next or prior record in the table, as well as to the top or bottom record in the table.
Designing the Navigation Buttons
Each of the buttons will have some characteristics and functionality in common, so it is a good idea to create a navigation button class. Then the individual buttons can easily derive this common appearance and functionality. This parent class is the Navbutton class defined later in this section.
Once the parent class is defined, the following subclasses define the functionality and appearance specific to each of the four navigation buttons: navTop, navPrior, navNext, navBottom.
Finally, a container class, vcr, is created and each of the navigation buttons is added to the container class. The container can be added to a form or a toolbar to provide table navigation functionality.
NAVBUTTON Class Definition
To create Navbutton, save the following six class definitions (Navbutton, navTop, navBottom, navPrior, navNext, and vcr) to a program file such as Navclass.prg.
Definition of the Generic Navigation Commandbutton Class
Code
Comments
DEFINE CLASS Navbutton AS COMMANDBUTTON Height = 25 Width = 25 TableAlias = “”
Define the parent class of the navigation buttons.
Give the class some dimensions. Include a custom property, TableAlias, to hold the name of the alias to navigate through.
PROCEDURE Click IF NOT EMPTY(This.TableAlias) SELECT (This.TableAlias) ENDIF ENDPROC
If TableAlias has been set, this parent class procedure selects the alias before the actual navigation code in the subclasses is executed. Otherwise, assume that the user wants to navigate through the table in the currently selected work area.
Using _SCREEN.ActiveForm.Refresh instead of THISFORM.Refresh allows you to add the class to a form or a toolbar and have it function equally well.
ENDDEFINE
End the class definition.
The specific navigation buttons are all based on the Navbutton class. The following code defines the Top button for the set of navigation buttons. The remaining three navigation buttons are defined in the following table. The four class definitions are similar, so only the first one has extensive comments.
Definition of the Top Navigation Button Class
Code
Comments
DEFINE CLASS navTop AS Navbutton Caption = “|<“
Define the Top navigation button class and set the Caption property.
PROCEDURE Click
Create method code to be executed when the Click event for the control occurs.
DODEFAULT( ) GO TOP THIS.RefreshForm
Call the Click event code in the parent class, Navbutton, so that the appropriate alias can be selected if the TableAlias property has been set.
Include the code to set the record pointer to the first record in the table: GO TOP.
Call the RefreshForm method in the parent class. It is not necessary to use the scope resolution operator (::) in this case because there is no method in the subclass with the same name as the method in the parent class. On the other hand, both the parent and the subclass have method code for the Click event.
ENDPROC
End the Click procedure.
ENDDEFINE
End the class definition.
The other navigation buttons have similar class definitions.
Definition of the Other Navigation Button Classes
Code
Comments
DEFINE CLASS navNext AS Navbutton Caption = “>”
Define the Next navigation button class and set the Caption property.
PROCEDURE Click DODEFAULT( ) SKIP 1 IF EOF( ) GO BOTTOM ENDIF THIS.RefreshForm ENDPROC ENDDEFINE
Include the code to set the record pointer to the next record in the table.
End the class definition.
DEFINE CLASS navPrior AS Navbutton Caption = “<“
Define the Prior navigation button class and set the Caption property.
PROCEDURE Click DODEFAULT( ) SKIP –1 IF BOF( ) GO TOP ENDIF THIS.RefreshForm ENDPROC ENDDEFINE
Include the code to set the record pointer to the previous record in the table.
End the class definition.
DEFINE CLASS navBottom AS Navbutton Caption = “>|”
Define the Bottom navigation button class and set the Caption property.
PROCEDURE Click DODEFAULT( ) GO BOTTOM THIS.RefreshForm ENDPROC ENDDEFINE
Include the code to set the record pointer to the bottom record in the table.
End the class definition.
The following class definition contains all four navigation buttons so that they can be added as a unit to a form. The class also includes a method to set the TableAlias property of the buttons.
Definition of a Table Navigation Control Class
Code
Comments
DEFINE CLASS vcr AS CONTAINER Height = 25 Width = 100 Left = 3 Top = 3
Begin the class definition. The Height property is set to the same height as the command buttons it will contain.
ADD OBJECT cmdTop AS navTop ; WITH Left = 0 ADD OBJECT cmdPrior AS navPrior ; WITH Left = 25 ADD OBJECT cmdNext AS navNext ; WITH Left = 50 ADD OBJECT cmdBot AS navBottom ; WITH Left = 75
This method is used to set the TableAlias property of the buttons. TableAlias is defined in the parent class Navbutton.
You could also use the SetAll method to set this property: IF TYPE ("cTableAlias") = 'C' This.SetAll("TableAlias", "cTableAlias") ENDIF However, this would cause an error if an object were ever added to the class that did not have a TableAlias property.
ENDDEFINE
End class definition.
Once you have defined the class, you can subclass it or add it to a form.
Creating a Subclass Based on the New Class
You can also create subclasses based on vcr that have additional buttons such as Search, Edit, Save, and Quit. For example, vcr2 includes a Quit button:
Definition of a Table Navigation Control Subclass
Code
Comments
DEFINE CLASS vcr2 AS vcr ADD OBJECT cmdQuit AS COMMANDBUTTON WITH ; Caption = “Quit”,; Height = 25, ; Width = 50 Width = THIS.Width + THIS.cmdQuit.Width cmdQuit.Left = THIS.Width – ; THIS.cmdQuit.Width
Define a class based on vcr and add a command button to it.
PROCEDURE cmdQuit.CLICK RELEASE THISFORM ENDPROC
When the user clicks cmdQuit, this code releases the form.
ENDDEFINE
End class definition.
Vcr2 has everything that vcr does, plus the new command button, and you don’t have to rewrite any of the existing code.
Changes to VCR Reflected in the Subclass
Because of inheritance, changes to the parent class are reflected in all subclasses based on the parent. For example, you could let the user know that the bottom of the table has been reached by changing the IF EOF( ) statement in navNext.Click to the following:
IF EOF( )
GO BOTTOM
SET MESSAGE TO "Bottom of the table"
ELSE
SET MESSAGE TO
ENDIF
You could let the user know that the top of the table has been reached by changing the IF BOF( ) statement in navPrior.Click to the following:
IF BOF()
GO TOP
SET MESSAGE TO "Top of the table"
ELSE
SET MESSAGE TO
ENDIF
If these changes are made to the navNext and navPrior classes, they will also apply automatically to the appropriate buttons in vcr and vcr2.
Adding VCR to a Form Class
Once vcr is defined as a control, the control can be added in the definition of a container. For example, the following code added to Navclass.prg defines a form with added navigation buttons:
DEFINE CLASS NavForm AS Form
ADD OBJECT oVCR AS vcr
ENDDEFINE
Running the Form Containing VCR
Once the form subclass is defined, you can display it easily with the appropriate commands.
To display the form
Load the class definition: SET PROCEDURE TO navclass ADDITIVE
Create an object based on the navform class: frmTest = CREATEOBJECT(“navform”)
If you don’t call the SetTable method of oVCR (the VCR object in NavForm) when the user clicks the navigation buttons, the record pointer moves in the table in the currently selected work area. You can call the SetTable method to specify what table to move through.
frmTest.oVCR.SetTable("customer")
Note When the user closes the form, frmTest is set to a null value (.NULL.). To release the object variable from memory, use the RELEASE command. Object variables created in program files are released from memory when the program is completed.
Definition of a Grid Control
A grid contains columns, which in turn can contain headers and any other control. The default control contained in a column is a text box, so that the default functionality of the grid approximates a Browse window. However, the underlying architecture of the grid opens it up to endless extensibility.
The following example creates a form that contains a Grid object with two columns. The second column contains a check box to display the values in a logical field in a table.
Grid control with a check box in one column
Definition of a Grid Class with a Check Box in a Grid Column
Code
Comments
DEFINE CLASS grdProducts AS Grid Left = 24 Top = 10 Width = 295 Height = 210 Visible = .T. RowHeight = 28 ColumnCount = 2
Start the class definition and set properties that determine the grid appearance.
When you set the ColumnCount property to 2, you add two columns to the grid. Each column contains a header with the name Header1. In addition, each column has an independent group of properties that determines its appearance and behavior.
When you set the ControlSource of a column, the column displays that field’s values for all the records in the table. Discontinu is a logical field.
Column2.Sparse = .F.
Column2 will contain the check box. Set the column’s Sparse property to .F. so that the check box will be visible in all rows, not just in the selected cell.
The AddObject method allows you to add an object to a container — in this case, a check box named chk1. Set the CurrentControl of the column to the check box so that the check box will be displayed. Make sure that the check box is visible. Set the caption to an empty string so that the default caption “chk1” won’t be displayed.
ENDDEFINE
End of the class definition.
The following class definition is the form that contains the grid. Both class definitions can be included in the same program file.
Definition of a Form Class that Contains the Grid Class
Code
Comments
DEFINE CLASS GridForm AS FORM Width = 330 Height = 250 Caption = “Grid Example” ADD OBJECT grid1 AS grdProducts
Create a form class and add an object, based on the grid class, to it.
PROCEDURE Destroy CLEAR EVENTS ENDPROC ENDDEFINE
The program that creates an object based on this class will use READ EVENTS. Including CLEAR EVENTS in the Destroy event of the form allows the program to finish running when the user closes the form. End of the class definition.
The following program opens the table with the fields to be displayed in the grid columns, creates an object based on the GridForm class, and issues the READ EVENTS command:
CLOSE DATABASE
OPEN DATABASE (HOME(2) + "data\testdata.dbc")
USE products
frmTest= CREATEOBJECT("GridForm")
frmTest.Show
READ EVENTS
This program can be included in the same file with the class definitions if it comes at the beginning of the file. You could also use the SET PROCEDURE TO command to specify the program with the class definitions and include this code in a separate program.
Object Reference Creation
Instead of making a copy of an object, you can create a reference to the object. A reference takes less memory than an additional object, can easily be passed between procedures, and can aid in writing generic code.
Returning a Reference to an Object
Sometimes, you might want to manipulate an object by means of one or more references to the object. For example, the following program defines a class, creates an object based on the class, and returns a reference to the object:
*--NEWINV.PRG
*--Returns a reference to a new invoice form.
frmInv = CREATEOBJECT("InvoiceForm")
RETURN frmInv
DEFINE CLASS InvoiceForm AS FORM
ADD OBJECT txtCompany AS TEXTBOX
* code to set properties, add other objects, and so on
ENDDEFINE
The following program establishes a reference to the object created in Newinv.prg. The reference variable can be manipulated in exactly the same way as the object variable can:
frmInvoice = NewInv() && store the object reference to a variable
frmInvoice.SHOW
You can also create a reference to an object on a form, as in the following example:
Tip Once you’ve created an object, you can use the DISPLAY OBJECTS command to display the object’s class hierarchy, property settings, contained objects, and available methods and events. You can fill an array with the properties (not the property settings), events, methods, and contained objects of an object with the AMEMBERS( ) function.
Releasing Objects and References from Memory
If a reference to an object exists, releasing the object does not clear the object from memory. For example, the following command releases frmInvoice, the original object:
RELEASE frmInvoice
However, because a reference to an object belonging to frmInvoice still exists, the object is not released from memory until txtCustName is released with the following command:
RELEASE txtCustName
Checking to See if an Object Exists
You can use the TYPE( ), ISNULL( ), and VARTYPE( ) functions to determine if an object exists. For example, the following lines of code check to see whether an object named oConnection exists:
IF TYPE("oConnection") = "O" AND NOT ISNULL(oConnection)
* Object exists
ELSE
* Object does not exist
ENDIF
NoteISNULL( ) is necessary because .NULL. is stored to the form object variable when a user closes a form, but the type of the variable remains “O”.
Arrays of Members and Objects
You can define members of classes as arrays. In the following example, choices is an array of controls:
DEFINE CLASS MoverListBox AS CONTAINER
DIMENSION choices[3]
ADD OBJECT lstFromListBox AS LISTBOX
ADD OBJECT lstToListBox AS LISTBOX
ADD OBJECT choices[1] AS COMMANDBUTTON
ADD OBJECT choices[2] AS COMMANDBUTTON
ADD OBJECT choices[3] AS CHECKBOX
PROCEDURE choices.CLICK
PARAMETER nIndex
DO CASE
CASE nIndex = 1
* code
CASE nIndex = 2
* code
CASE nIndex = 3
* code
ENDCASE
ENDPROC
ENDDEFINE
When the user clicks a control in an array of controls, Visual FoxPro passes the index number of the control to the Click event procedure. In this procedure, you can use a CASE statement to execute different code depending on which button was clicked.
Creating Arrays of Objects
You can also create arrays of objects. For example, MyArray holds five command buttons:
DIMENSION MyArray[5]
FOR x = 1 TO 5
MyArray[x] = CREATEOBJECT("COMMANDBUTTON")
ENDFOR
There are some considerations to keep in mind with arrays of objects:
You can’t assign an object to an entire array with one command. You need to assign the object to each member of the array individually.
You can’t assign a value to a property of an entire array. The following command would result in an error: MyArray.Enabled = .F.
When you redimension an object array so that it is larger than the original array, the new elements are initialized to false (.F.), as is the case with all arrays in Visual FoxPro. When you redimension an object array so that it is smaller than the original array, the objects with a subscript greater than the largest new subscript are released.
Data Storage with Objects
In object-oriented languages, a class offers a useful and convenient vehicle for storing data and procedures related to an entity. For example, you could define a customer class to hold information about a customer as well as a method to calculate the customer’s age:
DEFINE CLASS customer AS CUSTOM
LastName = ""
FirstName = ""
Birthday = { - - }
PROCEDURE Age
IF !EMPTY(THIS.Birthday)
RETURN YEAR(DATE()) - YEAR(THIS.Birthday)
ELSE
RETURN 0
ENDIF
ENDPROC
ENDDEFINE
However, data stored in objects based on the customer class are stored only in memory. If this data were in a table, the table would be stored on disk. If you had more than one customer to keep track of, the table would give you access to all of the Visual FoxPro database management commands and functions. As a result, you could quickly locate information, sort it, group it, perform calculations on it, create reports and queries based on it, and so on.
Storing and manipulating data in databases and tables is what Visual FoxPro does best. There are times, however, when you’ll want to store data in objects. Usually, the data will be significant only while your application is running and it will pertain to a single entity.
For example, in an application that includes a security system, you would typically have a table of users who have access to the application. The table would include user identification, password, and access level. Once a user has logged on, you won’t need all the information in the table. All you need is information about the current user, and this information can be easily stored and manipulated in an object. The following class definition, for example, initiates a logon when an object based on the class is created:
DEFINE CLASS NewUser AS CUSTOM
PROTECTED LogonTime, AccessLevel
UserId = ""
PassWord = ""
LogonTime = { - - : : }
AccessLevel = 0
PROCEDURE Init
DO FORM LOGON WITH ; && assuming you have created this form
This.UserId, ;
This.PassWord, ;
This.AccessLevel
This.LogonTime = DATETIME( )
ENDPROC
* Create methods to return protected property values.
PROCEDURE GetLogonTime
RETURN This.LogonTime
ENDPROC
PROCEDURE GetAccessLevel
RETURN This.AccessLevel
ENDPROC
ENDDEFINE
In the main program of your application, you could create an object based on the NewUserclass:
oUser = CREATEOBJECT('NewUser')
oUser.Logon
Throughout your application, when you need information about the current user, you can get it from the oUser object. For example:
IF oUser.GetAccessLevel( ) >= 4
DO ADMIN.MPR
ENDIF
Object and Data Integration
In most applications, you can best utilize the power of Visual FoxPro by integrating objects and data. Most Visual FoxPro classes have properties and methods that allow you to integrate the power of a relational database manager and a full object-oriented system.
Properties for Integrating Visual FoxPro Classes and Database Data
Because these data properties can be changed at design or run time, you can create generic controls with encapsulated functionality that operate on diverse data.
You can set the properties of an object at run time or design time.
To set a property
Use this syntax: Container.Object.Property = Value For example, the following statements set various properties of a text box named txtDate on a form named frmPhoneLog: frmPhoneLog.txtDate.Value = DATE( ) && Display the current date frmPhoneLog.txtDate.Enabled = .T. && The control is enabled frmPhoneLog.txtDate.ForeColor = RGB(0,0,0) && black text frmPhoneLog.txtDate.BackColor = RGB(192,192,192) && gray background
For the property settings in the preceding examples, frmPhoneLog is the highest-level container object. If frmPhoneLog were contained in a form set, you would also need to include the form set in the parent path:
frsContacts.frmPhoneLog.txtDate.Value = DATE( )
Setting Multiple Properties
The WITH … ENDWITH structure simplifies setting multiple properties. For example, to set multiple properties of a column in a grid in a form in a form set, you could use the following syntax:
Methods that return values and are used in expressions must end in open and closed parentheses. For example, the following statement sets the caption of a form to the value returned from the user-defined method GetNewCaption:
Form1.Caption = Form1.GetNewCaption( )
Note Parameters passed to methods must be included in parentheses after the method name; for example, Form1.Show(nStyle). passes nStyle to Form1’s Show method code.
This comprehensive AutoCAD tutorial covers a wide range of essential commands and techniques. It begins with basic drawing and editing functions, including lines, circles, rectangles, and modifying objects. It then moves to more advanced topics such as working with layers, creating blocks, and setting up units. The series includes practical tips for efficient workflows, annotative scaling, dynamic blocks, and using the Design Center and tool palettes. Finally, it explains working in isometric view, line type settings, dimensioning, and working with different objects. This content is aimed at intermediate users looking to advance their AutoCAD proficiency.
AutoCAD Drawing and Modification Study Guide
Quiz
What is polar tracking, and why is it useful? Polar tracking is a feature that helps you draw lines at specific angles (e.g., 0, 90, 180, 270 degrees) by providing visual cues. It is useful for creating precise horizontal and vertical lines and drawings.
How do you draw a line with a specific length and angle? Use the line command, click for the start point, type the length, and then press the Tab key to lock the length, which allows you to enter the desired angle.
Explain the difference between a line and a polyline. A line is a single, independent segment, while a polyline is a sequence of connected line or arc segments treated as a single object.
What is object snap (OSNAP), and give two examples of OSNAP modes? Object snap allows you to accurately select specific points on existing objects, such as the endpoint or midpoint. Two examples are Endpoint (extremity of a line segment) and Midpoint (center of a line segment).
How can object snap tracking help you draw a line a specific distance from an existing point? Activate the command line. Hover the cursor over an endpoint, drag in the desired direction to see the “Extension” label, and then type the distance from the endpoint to start the new line.
Describe two ways to create a rectangle in AutoCAD. You can use the rectangle command and specify two opposite corners, either by clicking or by entering coordinates. Alternatively, you can draw four individual lines (or polylines) connected to form a rectangle.
Explain the difference between specifying the radius and diameter when drawing a circle. The radius is the distance from the center of the circle to its edge, while the diameter is the distance across the entire circle through the center (diameter = 2 * radius).
How do you move an object in AutoCAD and what is the importance of the base point? Select the “Move” command, select the object, and press enter. The base point is the reference point on the object that you use to move it to the new location.
How does the trim command work, and how does selecting different objects at the beginning affect the outcome? Trim is used to erase portions of objects. If you select all objects before trimming, you can trim any segment between intersections. If you select only specific objects, you can only trim segments up to those objects’ intersections.
What are grips, and how can they be used to edit objects? Grips are small blue squares that appear when you select an object. Clicking on a grip allows you to stretch, move, rotate, or otherwise modify the object.
Answer Key
Polar tracking is a feature that helps you draw lines at specific angles (e.g., 0, 90, 180, 270 degrees) by providing visual cues. It is useful for creating precise horizontal and vertical lines and drawings.
Use the line command, click for the start point, type the length, and then press the Tab key to lock the length, which allows you to enter the desired angle.
A line is a single, independent segment, while a polyline is a sequence of connected line or arc segments treated as a single object.
Object snap allows you to accurately select specific points on existing objects, such as the endpoint or midpoint. Two examples are Endpoint (extremity of a line segment) and Midpoint (center of a line segment).
Activate the command line. Hover the cursor over an endpoint, drag in the desired direction to see the “Extension” label, and then type the distance from the endpoint to start the new line.
You can use the rectangle command and specify two opposite corners, either by clicking or by entering coordinates. Alternatively, you can draw four individual lines (or polylines) connected to form a rectangle.
The radius is the distance from the center of the circle to its edge, while the diameter is the distance across the entire circle through the center (diameter = 2 * radius).
Select the “Move” command, select the object, and press enter. The base point is the reference point on the object that you use to move it to the new location.
Trim is used to erase portions of objects. If you select all objects before trimming, you can trim any segment between intersections. If you select only specific objects, you can only trim segments up to those objects’ intersections.
Grips are small blue squares that appear when you select an object. Clicking on a grip allows you to stretch, move, rotate, or otherwise modify the object.
Essay Questions
Discuss the importance of layers in AutoCAD. How do layers contribute to organization, and how can you control the visibility and properties of objects within different layers? Provide specific examples of how effective layer management can improve the efficiency of your workflow.
Explain the process of creating and using blocks in AutoCAD. What are the advantages of using blocks, and how can dynamic blocks enhance your design capabilities? Discuss the steps involved in creating a block, including selecting objects, defining a base point, and setting attributes.
Describe the steps involved in setting up a layout in AutoCAD for printing. How do you create viewports, manage scales, and add annotations in paper space? Discuss the importance of using layouts for creating professional-quality drawings.
Discuss the various methods for importing and exporting files in AutoCAD. What are the advantages and disadvantages of each format (e.g., DWG, DXF, PDF)? How can you ensure that your drawings are compatible with different software and platforms?
Explain the concept of external references (XREFs) in AutoCAD. How do XREFs facilitate collaboration and ensure consistency in large projects? Discuss the advantages and disadvantages of using XREFs, and provide examples of how they can be effectively implemented in a real-world design scenario.
Glossary of Key Terms
Alias: A shortened command name that you can type instead of the full command name (e.g., “L” for “Line”).
Angle: The direction of a line or arc in relation to the X-axis, measured in degrees.
Arc: A curved line segment that is part of a circle.
Base Point: The reference point used when moving, copying, rotating, or scaling an object.
Block: A collection of objects that are combined into a single, reusable entity.
Command Line: A text-based interface where you can type commands and view prompts.
Diameter: The distance across a circle through its center.
Endpoint: The point at which a line segment begins or ends.
Extend: A command used to lengthen a line or arc to meet another object.
Grips: Small blue squares that appear when you select an object, used for editing.
Horizontal: Parallel to the X-axis.
Isolate: To make the rest of layers disappear.
Join: To bring objects together.
Layers: Virtual sheets on which you place objects, used for organization and controlling visibility.
Layout: A paper space environment used for preparing drawings for printing.
Line: A straight line segment defined by two endpoints.
Midpoint: The point exactly halfway between the endpoints of a line segment.
Mirror: A command to copy objects symmetrically
Modify: To edit objects.
Object Snap (OSNAP): A feature that allows you to accurately select specific points on objects, such as endpoints, midpoints, and centers.
Offset: A command that creates a parallel copy of a line, curve, or polyline at a specified distance.
Orthogonal: At right angles; vertical or horizontal.
Polar Tracking: A feature that guides the cursor to specific angles, making it easier to draw lines at those angles.
Polyline: A connected sequence of line or arc segments treated as a single object.
Radius: The distance from the center of a circle to its edge.
Rectangle: A four-sided polygon with right angles.
Rotate: To rotate objects around it.
Stretch: To stretch figures.
Tab: the button above the caps lock.
Trim: A command used to erase portions of objects.
UCS (User Coordinate System): A coordinate system that defines the XY plane for drawing and editing.
Units: The measurement scale used in a drawing (e.g., millimeters, meters, inches).
Vertical: Perpendicular to the X-axis and parallel to the Y-axis.
Viewport: A window in paper space that displays a view of model space.
WCS (World Coordinate System): The default coordinate system in AutoCAD.
XREF (External Reference): A drawing file that is linked to another drawing file. Changes made to the XREF drawing are automatically reflected in the host drawing.
AutoCAD Tutorial: Mastering Essential Techniques and Features
Okay, here’s a briefing document summarizing the main themes and important ideas from the provided AutoCAD tutorial excerpts.
Briefing Document: AutoCAD Tutorial Excerpts
I. Overview:
This document summarizes key concepts and procedures covered in a multi-part AutoCAD tutorial. The excerpts focus on fundamental drawing techniques, object modification, advanced drawing features, annotation, and customization. The overall aim is to guide beginners through essential AutoCAD functionalities and enhance their precision and efficiency.
II. Main Themes and Ideas:
Fundamental Drawing Techniques: The tutorial emphasizes precise drawing through the use of polar tracking, object snaps, and orthogonal mode (“Ortho mode restrict cursor orthogonally”). It covers drawing lines, polylines, rectangles, circles, and arcs.
Polar Tracking: “I strongly suggest you to use the polar tracking whenever you are making precise drawings.” Polar tracking ensures lines are drawn at specific angles (e.g., 0, 90, 180, 270 degrees).
Object Snaps (OSNAP): Enable accurate connections between objects by snapping to endpoints, midpoints, intersections, etc. “This will allow us to make our drawings with the maximum precision.” The tutorial highlights endpoint, midpoint, and object snap tracking. “Object snap tracking this is a very useful function and I will explain it with an example because I think it’s easier to understand”
Polylines: Polylines create a connected sequence of lines as a single object. “A polyline is a connect sequence of lines created as a single object”
Object Modification: Essential commands like move, copy, rotate, offset, trim, extend, and mirror are explained.
Offset: Creates parallel lines or polylines at a specified distance. “With the command offset I can inscribe that polyline inside with a specific distance that distance is called offset distance”
Trim and Extend: Trim is used to cut parts of objects: “In AutoCAD we often need to cut parts of objects we have drawn before for that we can use the command trim”. Extend is used to extend lines to intersect with other objects: “This command is used to extend lines in the example here I want to extend this line to intersect the vertical line on the left”
Mirror: Creates symmetrical copies of objects. “with this command we can copy objects symmetrically This is how it looks also when we need to make a symmetrical drawing we can just draw half of it and then use mirror in order to complete the process without spending time in drawing”
Editing with Grips: The tutorial demonstrates how to use grips (small blue squares) to modify object geometry directly.
Grips at the extremities of lines can change the length or position of that point while keeping the other end in the same place
Grip in the middle can move the line without changing the length and direction
Units and Layers: The tutorial explains how to set drawing units and use layers to organize objects.
Units: “AutoCAD uses a dimensional units this means that it’s up to me to decide what is the unit of a line that has length of 2050 or 100”. Users can choose decimal (mm, meters) or architectural/engineering (inches, feet) units.
Layers: Layers allow for grouping and controlling the visibility and properties of objects. “Layers is how AutoCAD organizes objects” “There are also other advantages in using layers I can set up specific colors to to distinguish them another thing for easy access I can drag this window to the left and then I click on this icon to hide it automatically then I just need to drag over the tab to see the layers”
Blocks: Blocks are reusable objects composed of multiple entities. This segment covers creating, inserting, and editing blocks, including annotative blocks and dynamic blocks.
“Sometimes we draw something that it’s easier if it would be a single unit for example a door if we want to copy it I have to select all the objects that compound the door if we convert all these objects to a block they add like a single object”
Dynamic blocks are created with parameters to have variable options: “There are four possibilities to linear parameters so we add the stretch then select the stretch frame and I need to cover all this part and for the objects I select those here and also at the left I press enter then I have to close the block editor and you can see again the result of stretching a part of a block the parameter alignment this parameter can be useful to ali”
Layouts and Printing: Explains creating layouts (paper space) to prepare drawings for printing, including viewports and scaling.
Layouts have a paper space where text and annotations are inserted, and the model space where the objects are created: “In AutoCAD we have two modes paper mode and model mode where the objects I drew are and to go from one place to another it is by the layouts tab”
“With the layout we are able to print the drawing as we want it”
“We set a viewport to show a specific drawing with a specific scale we realize that in a small destruction we scroll the mouse wheel and it messes up all the scale and then I have to go to the scale list and click again in this case in one per 150. however there is a very useful tool here I can lock the viewport by clicking on this icon now even I am in the model space I can zoom or move in the same way as I was in the paper mode”
Importing and Exporting: Covers importing PDF files and exporting to PDF format. “This video will teach you how to import drawings from a PDF that was previously created in AutoCAD I can recover all the layers and the objects as this PDF has two pages first I need to click on the one that I want to import on PDF data to import itcom Vector geometry to import the lines poly lines circles arcs and so on if I click on true type text text created with a font that has this symbol will be automatically recognized as text in AutoCAD most fonts available are to type so usually this is not a problem”
Customization and Utilities: Includes setting up units, working with layers, setting up default printing configurations, and using utilities such as quick select and the calculator. It shows how to modify the AutoCAD interface like color setting of the grid.
It also shows that there is a quick calculator that goes from basic calculations to a bit more complex ones
“In the utilities panel you can find other tools at a small icons at the right the first one above is quick select if I click there I open this window where I can select objects by using filters for example I can specify a type of object or select by color”
Stretch Command: “Sometimes in AutoCAD we need to stretch figures let’s learn how it works first it’s important to have in mind that this operation doesn’t work for blocks as you can see here I have only lines and polylines let’s do it I am going to click on the command stretch it’s this icon here then I have to select the parts to actually stretch so I open the selection from the right just until here that I specify this base points as you can see I’m extending and moving objects to this side and as the dementia line was in the selection it is also readjusting”
Hatches: Is a drawing tool that is used to fill in closed areas: “In this section I will be talking about a drawing tool which is used to fill in closed areas it’s the command hatch but first I am going to create a new layer in this file”
Arrays: with this we can copy objects arranged in a pattern there are three different modes rectangular array polar array and path array I start with rectangular array and for that I just need to click on the button that’s the mode set by default”
Dimension Lines: The tutorial teaches how to draw dimension lines with precision:
“Now I am going to teach you how to draw dimension lines this is a classic feature for annotation in your drawings in this video you can see the dimension lines indicating its distances now to draw dimension lines there is a panel on the Home tab here or if we go to The annotation tab we can have all the tools”
Isometric Drafting “I’m going to focus on some functions of the status bar that I haven’t explained before in the previous tutorials I will start with the isometric Drafting and to understand how it works we are going to draw this simple Cube which is represented as a 2d isometric projection there are three different planes that we can work on the left right and top”
Object Snap Overrides Has a useful tool that not a lot of people know suppose we are drawing a line here and we want to connect it perpendicular with the diagonal line below as you see it’s only showing up the midpoint and the end point but if I click with the right button I can see object snap overrides I go there and I can choose a different mode in this case I click on perpendicular and now you can see the symbol appearing just click on it to make those lines orthogonal twitch other
Text Heights Text styles can be updated by selecting and then quick select and edit them all for size and other options
Customized Palletes Allows you to organize design tools by drag and dropping to specific tabs and ordering the tab
Design Center Tool allows you to drag and drop various objects from various templates into one to copy settings over to your drawing.
III. Key Takeaways:
Mastering fundamental drawing commands and object snaps is crucial for precision.
Layers are essential for organizing complex drawings.
Blocks save time and ensure consistency.
Layouts provide a structured way to prepare drawings for printing.
AutoCAD offers extensive customization options to suit individual workflows.
IV. Suggested Next Steps:
Practice the exercises provided in the video descriptions to reinforce learning.
Explore advanced features such as dynamic blocks and parametric design.
Customize AutoCAD’s interface and settings to optimize your workflow.
FAQ on AutoCAD Essentials
1. How do I draw a perfectly horizontal or vertical line in AutoCAD?
To draw precise horizontal or vertical lines, activate Polar Tracking (an icon in the status bar). With polar tracking on, dashed green lines will appear, indicating snapping to specific angles (0, 90, 180, 270 degrees by default). If Polar Tracking is off, even a line that looks horizontal may have a slight deviation. Alternatively, activate Ortho mode (another icon in the status bar). Ortho mode restricts cursor movement to only orthogonal directions (horizontal or vertical).
2. How do I draw a line with a specific length and angle?
Start the line command. Click to place the start point. Type the desired length and then press the Tab key. This locks the length, allowing you to specify the angle. Type the angle (e.g., 30 degrees) and press Enter. The line will be drawn with the specified length and angle relative to the X-axis (UCS coordinates).
3. What is the difference between a line and a polyline?
A line is a single, independent segment. A polyline is a sequence of connected line segments (and arcs) treated as a single object. If you draw a series of connected lines using the line command, each segment is a separate entity. If you draw the same shape using the polyline command, the entire shape is a single object. You can convert separate lines into a single polyline using the JOIN command.
4. What is Object Snap (OSNAP), and how do I use it?
Object Snap allows you to precisely snap to specific points on existing objects (e.g., endpoints, midpoints, intersections, centers). Activate Object Snap (an icon in the status bar). Click the small arrow next to the Object Snap icon to view and select active OSNAP modes (endpoint, midpoint, etc.). When drawing, move the cursor near the desired snap point; a green marker (e.g., square for endpoint, triangle for midpoint) will appear, indicating the snap point. Click to precisely snap to that point.
5. What is Object Snap Tracking, and how is it useful?
Object Snap Tracking allows you to create extension lines from object snap points. This lets you start a new line at a precise distance from an existing point. For example, to start a line 30 units to the right of an endpoint: activate Object Snap Tracking, hover the cursor over the endpoint, drag it to the right without clicking until an extension line appears, type “30,” and press Enter. This starts the new line 30 units from the endpoint. You can also use it to intersect extension lines with polar tracking to make more complex, yet precise drawings.
6. How do I move, copy, rotate, or offset objects in AutoCAD?
These are fundamental modifying commands:
Move: Select the object, specify a base point, and move the object to the desired location, typing in a distance if needed.
Copy: Works similarly to move but creates a duplicate of the object.
Rotate: Select the object, specify a base point (around which the object will rotate), and specify the rotation angle (or use the “Reference” option for rotation relative to an existing angle).
Offset: Creates a parallel copy of a line or a polyline at a specified distance. Type the offset distance, select the object, and click on the side where you want to create the offset (inside or outside).
7. How do I trim or extend lines in AutoCAD?
Trim: Removes parts of objects that lie beyond a defined boundary (another object or intersection). Activate trim, select the cutting edges (boundaries), press Enter, and then click on the parts of the objects you want to trim away.
Extend: Extends lines or other objects to meet a defined boundary. Activate extend, select the boundary object, press Enter, and then click on the part of the object you want to extend.
8. How do I set up units for my AutoCAD drawing?
AutoCAD works with dimensional units, meaning that lines can be drawn with a length of 2, 50 or 100 without specifying if it’s meters, millimeters or inches. This makes it necessary to set up the unit properties to have accurate drawings. Type UNITS and press Enter to open the Drawing Units dialog box. Under “Length,” choose the desired format (Decimal for millimeters or meters, Engineering or Architectural for inches and feet). Select the desired precision. Under “Angle,” select the desired angle units. Under “Insertion scale,” choose the unit you intend to use for your drawing (millimeters, meters, inches, etc.).
Introduction to AutoCAD for Beginners
Overview of the Course
Hello friends, my name is Fabio, and welcome to this complete course for beginners in AutoCAD. This video is intended for learners who are using the software for the first time. The course is 4 hours long, giving us ample time to explore all the basics and delve deeper into some topics that I find particularly useful. This video is a compilation of three tutorials that I decided to combine into one, as I know some users prefer to have all the content in a single video. However, if you prefer to watch them separately, you can find the links in the description of this video. In this course, I will be using AutoCAD 2020 and AutoCAD 2022 in the last tutorial. Don’t worry if you have a different version, even if it’s a bit older, as I will conduct the lessons in a way that works for all versions.
AutoCAD Interface and Basic Tools
The Default Display
When you open AutoCAD, you are greeted with the default display, which consists of different areas. At the top left, you’ll find the application icon, which is the menu where you can open a new document, open a file, or perform operations related to saving or exporting a file. The main part at the top is called the ribbon, where you’ll find the majority of tools you’ll need during your work. The ribbon is divided into tabs, such as the Home tab, which contains the most frequently used icons. If you switch to the Insert tab, you’ll find icons related to inserting objects into your drawing. Within each tab, the icons are further subgrouped into panels. For example, in the Home tab, the first panel contains icons for drawing actions, the second panel for modifying objects, and the third panel for annotation icons. Additionally, when you click on a panel that has an arrow facing down, it shows extra icons that are used less frequently.
Using Tools in AutoCAD
Let’s start by learning how to use some basic tools in AutoCAD. For example, if you want to draw a line, you can click on the line icon, go to the workspace, click for the first point, and then click again for the second point. It’s that simple. However, I want you to pay attention to the command bar, which shows the operations that are taking place during your project. For instance, when you click on the line icon, the command bar will display “Line specify first point.” The first word in capitals is the command name, in this case, “Line.” The prompt sentence tells you what you should do next. After specifying the first point, it will ask you to specify the next point. You can continue drawing lines, but if you want to exit the line command, you can press the Escape key. In conclusion, to perform any action in AutoCAD, you can type its command name, for example, “Line,” and press Enter. You can then draw a line and press the Escape key to leave the command.
Drawing Lines and Circles
Drawing a Line with Specific Length and Direction
Now that you know how to draw a basic line, let’s learn how to draw a line with a specific length and direction. To draw a horizontal line, you need to activate the Line command by clicking on the icon or typing “L” (the alias for Line) and pressing Enter. Click anywhere on the workspace for the start point, then drag the cursor to the right. You’ll notice a green dashed line with a label saying “Polar” and “0 degrees.” If you click now, the line becomes completely horizontal. This happens because the polar tracking is turned on. Polar tracking allows the cursor to snap to certain angles, which are set by default to 0, 90, 180, and 270 degrees, making the lines vertical and horizontal. If you turn off the polar tracking, you’ll notice that the dashed green line disappears, and even if the line looks horizontal, there will always be a slight deviation. Therefore, I strongly suggest using polar tracking whenever you are making precise drawings.
Drawing a Circle
Next, let’s learn how to draw a circle. You can click on the circle icon or type the command name, which is “Circle.” Each command also has a shortcut called an alias, so you don’t need to type the full name. For example, “C” is the shortcut for the Circle command. During this tutorial, each time I introduce a new command, I will make an annotation on the left part of the screen showing the command name, the alias, and its location on the ribbon. This way of inserting commands makes AutoCAD easy to switch between different versions. For example, if you are using AutoCAD 2007, which has a different display, you can still work with no problems because the command names and their shortcuts are the same. The same applies to the Mac version of AutoCAD, even though the icons are in different places. You can just type the command names and don’t need to worry about finding them on the screen.
Using the Mouse in AutoCAD
Zooming and Moving the Workspace
Having a mouse is very important for working in AutoCAD, as it’s much more comfortable than using just a touchpad, especially for zooming or moving the workspace area. Let’s see the functions of the mouse buttons. With the mouse wheel, you can zoom in and out of the workspace. It’s very simple: if you scroll up, you zoom in, and if you scroll down, you zoom out. The zooming always applies to the exact location of the pointer. For example, if you want to zoom in on specific objects, you need to move the pointer over them and scroll up. To move the workspace area, press and hold the mouse wheel. When you see a hand icon, you can move around the workspace.
Selecting Objects
Clicking with the left mouse button allows you to select objects. For example, if you click on a circle, it will be selected. If you want to select multiple objects, you can click on one object and then click on another without pressing the Ctrl key, unlike other programs. However, if you have a bunch of objects to select, it could take a long time to select them all. For that reason, if you click in an empty space, a selection area opens, allowing you to select more than one object. There are two kinds of selection areas: if you open the area to the right, the color is blue, and if you open it to the left, the area appears in green. The difference is that when you open to the right (blue color), you have to cover the entire object to select it, whereas if you open to the left (green color), it’s enough if you only cover one part of the object. You can also tell if an object is going to be selected when you see it turning bold.
Advanced Drawing Techniques
Using Object Snap for Precision
Object Snap is a very important function in AutoCAD that allows you to make your drawings with maximum precision. For example, if you want to draw a line that connects to the endpoint of another line, you can use the Endpoint object snap. When you move the cursor near the endpoint of a line, a green square will appear, indicating that you can snap to that point. Similarly, you can use the Midpoint object snap to draw a line from the middle point of another line. Object Snap Tracking is another useful function that allows you to draw lines at specific distances from existing objects. For example, if you want to draw a line that is 30 units away from the endpoint of another line, you can use Object Snap Tracking to ensure that the new line starts at the correct distance.
Drawing Rectangles and Circles
To draw a rectangle, you can use the Rectangle command, which is essentially a faster way to draw a polyline with four sides. You only need to specify two points: the first corner and the opposite corner. You can also insert coordinates to specify the exact dimensions of the rectangle. For example, if you want to draw a rectangle that is 40 units wide and 20 units tall, you can type “40” for the x-axis, press Tab, and then type “20” for the y-axis. To draw a circle, you can click on the Circle icon and specify the center point and the radius. For example, if you want to draw a circle with a radius of 20 units, you can type “20” after specifying the center point. You can also use the Diameter option to specify the diameter of the circle instead of the radius.
Modifying Objects in AutoCAD
Moving and Copying Objects
In AutoCAD, you often need to move or copy objects to different locations. The Move command allows you to move an object to a new position. For example, if you want to move a rectangle to a distance of 60 units to the right, you can use the Move command, select the rectangle, specify a base point, and then type “60” to move it horizontally. The Copy command works similarly to the Move command, but instead of moving the object, it creates a copy of the object at the new location. You can continue copying the object as many times as you want, and when you’re done, you can press Escape to exit the command.
Rotating and Scaling Objects
The Rotate command allows you to rotate objects around a base point. For example, if you want to rotate a set of objects by 90 degrees, you can use the Rotate command, select the objects, specify a base point, and then type “90” to rotate them. The Scale command allows you to resize objects by a scale factor. For example, if you want to double the size of an object, you can use the Scale command, select the object, specify a base point, and then type “2” to scale it up. You can also use the Reference option to scale an object based on a reference line. For example, if you have a reference line that is 50 units long and you want to scale an object so that the reference line becomes 55 units long, you can use the Reference option to achieve this.
Working with Layers and Blocks
Organizing Objects with Layers
Layers are a way to organize objects in AutoCAD. For example, if you are working on a floor plan, you can create separate layers for walls, doors, windows, and text labels. This allows you to easily control the visibility and properties of different types of objects. You can create a new layer by clicking on the Layer Properties Manager and then clicking on the New Layer button. You can then set the name, color, and line type for the new layer. Once you have created a layer, you can assign objects to that layer by selecting the objects and then choosing the layer from the Layer drop-down menu.
Creating and Using Blocks
Blocks are a way to group objects together so that they can be treated as a single object. For example, if you have a door that consists of several lines and arcs, you can convert it into a block so that you can easily move, copy, or scale the door as a single object. To create a block, you can use the Block command, select the objects that you want to include in the block, and then specify a base point. Once you have created a block, you can insert it into your drawing by using the Insert command. You can also edit a block by using the Block Editor, which allows you to make changes to the block that will be applied to all instances of the block in your drawing.
Printing and Plotting in AutoCAD
Setting Up Layouts for Printing
In AutoCAD, the Model tab is where you create your drawings, and the Layout tabs are used for printing. When you switch to a Layout tab, you’ll see a paper with a specific size, and the drawings on the paper are what will be printed. To print properly, you should specify the paper size that you need. You can do this by right-clicking on the Layout tab and selecting Page Setup Manager. In the Page Setup Manager, you can choose the printer, paper size, and orientation (landscape or portrait). Once you have set up the page, you can create a viewport, which is like a window into your model space. You can then adjust the scale of the viewport to fit your drawing on the paper.
Printing Tips
When you are ready to print, you can right-click on the Layout tab and select Plot. In the Plot dialog box, you can choose the printer, paper size, and other settings. If you want to hide the viewport when you print, you can create a new layer for the viewport and then freeze that layer. This will make the viewport invisible on the printed page. You can also set up different colors for printing by changing the viewport color in the Layer Properties Manager. For example, if your drawing has light colors that are hard to see on a white paper, you can change the viewport color to a darker color to make the drawing more visible when printed.
Conclusion
In this course, we have covered the basics of AutoCAD, including the interface, drawing tools, modifying objects, working with layers and blocks, and printing. By practicing these skills, you will be able to create precise and professional drawings in AutoCAD. Remember to take advantage of the exercises provided in the video description to strengthen your knowledge. As you continue to work with AutoCAD, you will discover more advanced features and techniques that will help you become even more proficient in using this powerful software. Thank you for watching, and I hope this course has been helpful in getting you started with AutoCAD!
Autocad – Complete course for beginners
The Original Text
Hello friends my name is Fabio and welcome to this complete course for beginners in AutoCAD this video is intended for Learners that are using the software for the first time but as you can see it has 4 hours of length here we will have time to explore all the basics and get deeper in some topics that I find useful to learn in fact this video is a compilation of three tutorials that I decided to put them all together in just one as I know that some users prefer to learn with the full content in only one video but of course in the case you prefer to watch them separately please find the links in the description of this video then you will notice that in this video I’m using the versions AutoCAD 2020 and the version 2022 in the last tutorial of the course but don’t worry in the case you have a different version even if it is a bit older that’s not going to be an issue because I will conduct a lesson in a way that works for all now it’s time to start [Music] okay this is the AutoCAD default display which consists in different areas above at the left you find the application icon this is the menu where I can open a new document open a file or do operations regarding saving or exporting a file then the main part at the top is called the ribbon there you find the majority of tools you will need during the program right above so you can find these steps which group the buttons in different categories for example the current one is the Home tab which has the most used icons if you switch to the insert tab I find in this case icons related to this category then inside the specific tab the icons are subgrouped in panels for example in the in the Home tab the first panel have the icons which can perform drawing actions in the second panel they are related to modifying objects and on the third panel are The annotation icons additionally when you click in a panel that has an arrow facing down it shows extra icons which are used less often has a diagonal Arrow at the right I can access to the settings window of this category now let’s show you how to use tools in AutoCAD for example imagine I want to draw a line as you may guess I can click in the icon here I go to the workspace I click for the first point and then where I want the second point I click again simple then I’m going to repeat the process but this time I want you to pay attention to this the command bar this shows the operations that are taking place during the project I will show you I click again in the line icon and you can notice here line specify first point the first words which appears in capitals is the command name in this case line then that’s the prompt sentence which tells me what I should do next though I click here to specify the first point then it asks to specify next Point click again as you see I just draw a line but it keeps asking for specifying another point it would draw a new line as I don’t want I can press escape to exit the line command in conclusion to perform any action in AutoCAD I can type its command name for example I type line and press enter and I can draw a line then press the button escape to leave the command now I want to draw a circle I can click in its icon or type the command name which is circle additionally each command has a shortcut called Alias so I don’t need to type its full name for example L is the shortcut for the command line and C is a shortcut for Circle during this tutorial each time I introduce a new command I make an annotation at the left part of the screen showing the command name the Alias and its location on the ribbon this way of inserting commands makes AutoCAD easy to switch from different versions if for any reason I’m going to a computer that has AutoCAD 2007 which had a different display than this one I can still work with no problems because the command names and their shortcuts are the same of course some functions were not available in that time but almost all the basics didn’t change the same applies to the version in Mac even AutoCAD 2020 there has a different display the icons are in different places you can just type the command names and don’t need to worry to find them out on the screen how to use the mouse in the workspace having a mouse is very important for working in AutoCAD as it’s much more comfortable than using just a touchpad especially for zooming or moving the workspace area let’s see the functions of the mouse buttons here I attach this image to help you most wheel with the mouse wheel I can zoom the workspace it’s very simple if I scroll up I zoom in if I scroll down I zoom out the zooming always applies to the exact location of the pointer for example in this situation if you want to zoom these objects I need to move the pointer over them scroll up and you notice they are filling all the screen simple to move the workspace area press and hold the wheel when you see this hand you can move around left button clicking with the left button I can select objects like this circle if I want to select the circle and the line I can click first in one then in the second without pressing the Ctrl key unlike other programs but now imagine you have a bunch of objects to select it could take a long time to select them all for that reason if I click in an empty space a selection area opens this allows me to select more than one object however this is important there are two kinds of selection if I open the area to the right the color is blue if I open to the left the area appears in green color what’s the difference when I open to the right blue color I have to cover the entire object to select it if I would open to the left green color it’s enough if I only cover one part also you can understand if the object is going to be selected when you see it turning bold now the right button the right button opens this panel with several options you can choose but when you select an object and right click you can access for example to its properties I click it’s a long list over here I’m going to close it however there is a compact version of properties quick properties which contains the most important features for this line you can see the object type line color layer line type and length by the way in the quick properties of this circle some of the topics didn’t pop up for the line as they are more relevant for circles like the diameter radius or area in this capture I’m going to teach you to draw lines properly the line is probably the most basic tool and the one you will use most of the time before I showed how to draw a line but without any specified length or Direction I mean if it’s horizontal vertical or if it makes an angle with the x-axis for example that’s exactly what you will learn the next few minutes draw a horizontal line to draw a horizontal line I need to activate first the command line I can click on the icon there or type the command name as you remember from the first capture or I can simply Type L it’s the Alias for line and press enter I click anywhere on the workspace for the start point then I’ll drag the cursor to the right and you can notice the Stars green line with this label saying polar and 0 degrees if I click right now the line becomes completely horizontal this happens because I have the polar tracking turned on this icon located in the status bar the polar tracking allows the cursor snapping to certain angles by default these angles are set for 0 degrees 90 degrees 180 degrees and 270 degrees making the lines vertical and horizontal now look what would happen if the polar tracking is off click on the icon it’s disabled now then I’m going to draw a line again Type L press enter click for placing the start point then as I’m trying to draw a horizontal line I realize that the dashed green line is not there that means when I click even the line Looks horizontal there will always be a slight deviation so I strongly suggest you to use the polar tracking whenever you are making precise drawings draw a line with specific length this time I’m going to draw again the horizontal line but with a precise length of 100 it doesn’t matter the units for now as the last command used was line I can press enter to revert to the previous one look it turned on again the command I click I move horizontally to the right now that the line is on the direction I desire I can type 100 and press enter easy you just drew a horizontal line with a length of 100. but be aware when I type the length I cannot change the direction anymore see I move the mouse and nothing happens so if it’s not on the direction you want you can press Escape now I can make it vertical for example insert the length again and press enter to confirm this I click on the line right click go to Quick properties and here you have it length 100. Ursa mode if I want to draw only orthogonal lines I can click on the icon also mode restrict cursor orthogonally then when I’m drawing a line I can only make it horizontal or vertical this can be useful if I’m at a part of a project where I just need those type of lines like in the example here now let’s draw this line here with 70f lengths but with a 30 degrees angle from the x-axis which you can check looking at the UCS coordinates they are by default located at the left corner of the screen here so I draw again a line start point I type 70 but this time instead of pushing enter I press the button tab the one above the caps lock with this way I locked the length but I can choose the direction I placed a pointer more or less here type 30 and press enter as you see it’s quite simple then look at these different situation the line makes the same angle but in the opposite direction I do the same as before type the length then look at this label showing the current angle while I’m moving the cursor around it’s increasing until I reach half circle 180 degrees then it decreases as now it’s showing the other side angle basically if I’m below the x-axis and type 30 the angle starts again in the same place but in a clockwise Direction next to the line icon is the polyline a polyline is a connect sequence of lines created as a single object for example let’s draw this exercise here I click in polyline choose a start point to draw the first line go up and make sure you have the polar mode switched on type 20 press enter then to the right I Type 25 press enter again and finally vertically down this is important always click when the polar tracking is on the screen type 20 again press enter and Escape so if I click in the polyline it selects the full sequence as you see although I could use the command line to draw the same example all the lines would be considered as separate objects now that you know the basics to draw lines I want to introduce to you a very important function in AutoCAD the object snap this will allow us to make our drawings with the maximum precision take a look at the next example let’s draw it I can use either line or polyline command I choose polyline I’m going to type its shortcut PL OT the first line then the vertical one as there is no line to continue here I press Escape now the third line has to be connected to this intersection I turn on the command line I move the cursor near the left end of this line and look at this green square appearing here saying endpoint the same happens when I go to the other side you can see it again if I click right now the next line starts automatically from that point and it means the three lines are now connected to each other Type 25 and press enter those green squares only appear because the object snap is active it’s this icon at the status bar at the arrow just next I can see the modes that are currently active see here the end point which is an extremity everline segment now I’m going to introduce you also the midpoint first I’m going to click in it because it’s not active then I want to draw a line from the middle point of this one I activate the command line C this triangle indicates the midpoint I click now and the next line starts exactly from there object snap tracking this is a very useful function and I will explain it with an example because I think it’s easier to understand we have this example here and we want to draw this line which is located at a distance of 30 from the right I turn on the command line place the cursor on this endpoint drag left slowly so that I see this label that says extension in this moment if I type 30 the new line starts with that distance from the end point it’s simple and with this we can avoid drawing extra lines then you just need to draw the remaining objects to connect this line with the rectangle below drag it down until I see this cross here now click and press Escape another way to use object snap tracking can be when I’m drawing this rectangle I can draw an extension line up from this point until I intersect the polar tracking of the line I’m making like this so this kind of things are very interesting to play around now you need to make a bit of practice to strengthen the knowledge you got in this video for that reason I prepared these exercises for you you can get them in PDF by clicking on the link available in the description part 2. I am going to explain to you briefly more drawing commands rectangle a rectangle is in reality a polyline it’s just a faster way to draw this kind of objects as I just need to specify two points I’m going to show you the command is this one specify the first point and then I only need the opposite corner I can simply click to place it or insert a coordinates regarding the first point that’s where I’m going to do the first blank is for the x-axis type 40. then I press tab to switch to the second coordinate this one is for the y-axis type 20 and press enter again in fact what I have done was inserting the length and the width simple however as I still have to take into consideration that UCS coordinates sometimes the values might be negative let’s suppose I draw another rectangle but with the start point the x coordinates would be -40. click for the start point then type -40 press tab and that’s the Y coordinates are positive I type 20. here you have the result Circle to insert a circle in AutoCAD I can click in this icon as I believe you guessed then just follow the prompts to draw the example here specify center point of the circle OK I click anywhere then specify radius of circle it is 20. I type that value and press enter let’s do the next now check out this tip as I want to use again the command circle press enter the system automatically reactivates the previous action this is very important to know it saves time I am going to draw the same Circle again now look to the prompt at the command bar specify radius of circle or diameter so instead of typing a radius I can switch to typing a diameter I do it by clicking on it or simply type the first letter d then press enter as I’m drawing the same Circle the value is 2 times the radius 40. press enter again okay this is just one of the several ways to insert a circle if I click on the Arrow below the icon you can see all these options available that depends the situation that you are drawing Arc an arc is a section of a circle and like the previous command there is an arrow below the icon with different ways of specifying points I’m going to draw the Arc of this example above and the best option here is inserting the start point then the center and finally the end point by default AutoCAD draws The Arc in the clockwise Direction let’s click on the Arrow then find Start Center end click on the end point of this line for the start point the center is the intersection between both lines and finally the end point is this one see how the arc is being drawn clockwise modifying objects until this moment I taught you the most used commands to draw in AutoCAD in this section I will introduce to you commands that will help you in modifying objects and to be more effective while drawing I’m going to start with the basic ones move to move an object to a different place for example want to move the small rectangle to a distance of 60 to the right click on the icon select a rectangle press enter specify a point from where I want to move the object then I move to the right horizontally and type the distance of 60. press enter in the following example I want to move the rectangle to the other box which is located at the same distance from the corner as here I activate move again I select the object press enter but this time the base point it’s going to be the corner then I click in the next corner to move it there copy this command works in the same way as the command move I’m going to copy the object to the first rectangle I use this base point then I can copy it in this intersection then I realize I can keep copying the object the number of times I want do you see it’s very nice this and when I’m done I press Escape rotate to rotate objects I can use this command let’s see how it works I click on the icon select the objects press enter then I choose a base point where the objects can rotate around it as the bullet tracking is on I’m going to rotate them 90 degrees to this side another situation the same objects are in this position if I try to rotate them back to the position they were before the polar tracking doesn’t work this time however I can use a different way if you look to the prompt there is an option that says reference to use it I can either click on it with the mouse or type R usually the first letter is enough after I can specify a reference angle or draw a reference line let’s draw a reference line I prefer this click here for the first point then for the second point I choose this endpoint finally I can rotate until the polar tracking appears now look at this polyline with the command offset I can inscribe that polyline inside with a specific distance that distance is called offset distance and it has a length of 10 in this example let’s do it the icon of set is this one clicking it then for specify offset distance I type 10. select the polyline I move the pointer inside and click there to draw the new polyline by the way if I click outside the area the new polyline offsets outside the original one the command of set can also be applied to lines if I have this line and apply offset to it a new line shows up parallel to the first one now I want to show you a situation that happens to a lot of people I’m going to draw a rectangle with a command line then I want to offset the lines like before I type O to activate a command specify the distance of 10. and when I click to offset I realize I can only click on one line at a time and the result is different than when I applied to poly lines however I can easily merge lines in a polyline there is a command for it join I type join or I can still find the icon on the modify panel here it’s very simple select the lines to merge and press enter as you see now I have a polyline finally if I do offset again the result will be identical as my first example commentary in AutoCAD we often need to cut parts of objects we have drawn before for that we can use the command trim let’s check out how it works I’m going to start with a very simple example we have these lines and I want to erase this segment I click on the command trim is located there select both lines press enter then if I drag the pointer over here the screen shows that this part will be erased the same happens when I move the pointer to the other segments I click on this one and you see it disappearing it’s done to leave the command press enter or Escape look to this example this time we have three lines I turn on trim again select all the objects and then I can erase any segment between any intersection as you see now suppose I want to erase all this part of the horizontal line turn on trim the vertical line on the right I don’t need to select just the other two press enter and when I’m going to click on this line it erases everything from the intersection of the lines I have selected to the right maybe for this situation this didn’t make a big difference but look at this case here I want to delete all this part of the line if I select everything then I need to erase one by one it takes a long time so it’s better to only select the lines I’m going to use like this of course I can use stream not only for lines it works for other kinds of objects for example I want to change this drawing to that one I activate stream select everything press enter and finally click on the parts to erase extend this command is used to extend lines in the example here I want to extend this line to intersect the vertical line on the left I am going to click on the Arrow located next to the command trim then I select extend first I have to select not the line that I want to extend but the one where the extended lines will connect so it’s this one press enter then I select the line to extend to extend the line to the left I have to click on the left half in order to work look if I drag the pointer over the right half nothing happens I go slowly to the left and after passing the middle the extension appears again I click and press enter in this example I want to extend all the vertical lines on both sides I type EX press enter select both horizontal lines press enter again to extend the lines up I can open a selection area to cover the upper part of all vertical lines I click then I do the same for the part below to extend the lines down when I finish I press enter to exit the command of course in this situation there is a faster proceedment by opening an area that covers both line sites that extends both parts in just one step mirror with this command we can copy objects symmetrically this is how it looks also when we need to make a symmetrical drawing we can just draw half of it and then use mirror in order to complete the process without spending time in drawing let’s see how the command Mirror Works for these objects click on the icon select everything and press enter then the prompt asks me to draw a mirror line I’m going to insert the first point at a distance of 20 from the objects I Hove the mouse over this endpoint move right type 20 and press enter I’m going to draw the line vertically and you can see everything reflected as a mirror I click for the second point now the prompt sentence says erase Source objects I choose now to keep the original ones notice that all lengths are kept including the distance between the objects and the mirror line now check out these considerations about command mirror it doesn’t matter the length of the mirror line just the direction as you can see if I draw a long vertical line the result is the same only if I rotate it the objects are placed differently to make a symmetrical drawing I just need to draw half of it because if I draw a vertical mirror line in this end point the new mirrored objects connect to the original ones it’s simple sometimes I don’t want the original objects in the option erase Source objects I choose yes that’s the result editing objects using grips the blue icons that show up when I select an object are called grips and they allow me to edit it when I select the line there are three groups if I click in one at extremity I can change the position of that point keeping the other end in the same place if I click on the grip in the middle I can move the line without changing the length and direction now let’s see some editing tips change the line length by moving one of the ends I’m going to click on this icon I drag left I’m going to type 10 and the line length increases to 80. of course this also works if I want to make the line shorter click again this time I drag right type 10 and the line returns to its previous size to type a new length to the line I click on the grip drag left and this time I press the button tab and the input switches to the full length I am going to insert 120. then let’s check out how grapes work on polylines the end grips of each line Works in identical way I click on this one to change its position and you can see all the other vertexes don’t move of course this may cause me to deform the polyline now unlike the lines the grip on the middle has a rectangular shape I’m going to click on one and I can move that full line then the rest of the polyline has to adapt to its new position for example I move right type 10 and you can notice this line increases 10 of its total length so we reached the end of the second part of this tutorial now I prepared more exercises for you in order to practice what you have learned here the link is in the description of the video after don’t miss the third part of this course as I will keep teaching very important features for beginners as setup units work with layers platter drawing and more part three until here I taught you commands to draw objects and modify them but I haven’t mentioned any units for the dimensions when I was drawing lines I said draw a line with dimensioner 50 or 100. I didn’t say if it was meters millimeters inches or feet but I’m going to talk about this now first of all AutoCAD uses a dimensional units this means that it’s up to me to decide what is the unit of a line that has length of 2050 or 100. it’s very simple let’s suppose I want to make a project in millimeters that’s the unit I usually work with I want to insert a line with five millimeters of length I draw the line as usual and when I want to set up the length I type 5. then I’m going to insert a line that measures 1 meter I do the same but this time for the length I type 1000 because as you may know one meter is one thousand millimeters now let’s go to the unit properties window I type units and press enter here on the length section at the left you can choose the format for units of measure if you work in millimeters or meters you should use decimal units instead in some countries it’s more common to use inches and feet in this case engineering or architectural units are more suitable below you can set the Precision in this drawing I consider the units millimeters and I don’t need decimals so I choose the first option at the angle side I can choose the units for angles most of the time I use test symbol degrees but there are others here that could eventually be more suitable for you the units in insertion scale are used only when I insert objects or drawings from a different file usually when we start learning AutoCAD I don’t need to insert anything external but in my opinion it’s better to specify the unit I click on millimeters when I finish I click on OK to exit foreign layers is how AutoCAD organizes objects for example have a look to this file here I have two floor plans it’s a proposal for converting offices in Flats so instead of having the objects all together I decided to organize them in different layers I am going to click on this icon to open the layer properties manager here you can see that I created layers to group different categories of objects for example I placed the windows in one layer the walls in another and I did the same for the doors text labels and so on there are also other advantages in using layers I can set up specific colors to to distinguish them another thing for easy access I can drag this window to the left and then I click on this icon to hide it automatically then I just need to drag over the tab to see the layers now I am going to explain to you how we can work with layers and tell you some considerations new layer if I want to create a new layer I click on a blank space on this window with the right button then I click on new layer then I can set up a name for the new layer for example stairs and if I click on the color for example I can change it to the one that I want I’m going to choose this yellow under line type I have a continuous line by default however if I click on load I can find several line types dashed lines or other formats clicking on this light I can turn off a layer for example I’m going to turn off the layer doors and you can see those objects disappearing from the screen there is also the mode freeze even it looks like it has the same effect as turning it off freezing a layer releases it from memory you can notice the difference in the performance when you work with very large drawings especially freezing layers that contain loads of 3D objects now suppose that I want to move these objects to the layer stairs I have to select them go to the layer tab and change to stairs you can see that they changed the color then I want to draw a new line in a specific layer first choose the layer and then I can draw the line it’s simple always specify the layer before drawing to avoid changing it after isolate layers to isolate the layer I can click on this icon then I click on one object of the layer that I want to isolate this operation locks all the objects inside the other layers meaning that I cannot edit them now this is useful for me to modify objects from this layer text for example I want to move all the text to the left I activate the command move open the selection window to select the objects click for a base Point move left and click again to restore all layers that were locked before I click on the icon right below and isolate layer 0. if I move the pointer over the layer properties you can check here the layer 0. default layer anytime I start a new file in any project I recommend to you to keep this layer without objects there you cannot rename it or delete it however this layer can be useful for creating blocks which is what I’m going to explain on the next section of this video sometimes we draw something that it’s easier if it would be a single unit for example a door if we want to copy it I have to select all the objects that compound the door if we convert all these objects to a block they add like a single object so I want to convert this door to a block as it’s on the floor plan to be easier to select it I’m going to isolate the layer where the objects are located in click on the icon isolate and click on any object of the door press enter and the layer doors became isolated let’s use the command copy now it’s very easy to select only the door with the selection area that’s because all the other layers are locked press enter and I can copy the door outside the plan creating a block before creating a block I’m going to move these objects to the layer 0. by doing that I can later move the block to the layer I desire and it gets its properties I select the objects and I’m going to click on the icon create a block the block definition window appears here I can set up a base point for the door I choose this corner here back to the window I have to write a name for the block I name it as door when I finish I click on OK so the block is created if I click on any part of the door you can see that this is now a single object now I’m going to change the block to the layer that I want and you can see while I’m scrolling here it changes the color to match the new layer however if I created the block with objects in another layer for example stairs I’m going to create the block then I’m going to change the layer of the block to another one but it keeps the properties of the layer stairs the layer 0 on the other hand means that the objects don’t have any layer assigned check out this example add doors to the floor plan as you know I have my new block here with the command copy I can insert them easily in the floor plan I just have to click on the endpoints of these lines a great advantage of using blocks is the ease of modifying them I go to this button that says edit block then I choose the block door I click on OK this is the block editor workspace and also a new tab for editing blocks appeared on the ribbon here I can make all the changes that I want to this block for example I’m going to draw a circle here then I close the block editor and save the changes as you can see all the block references of the black door have a circle inside which can save amounts of time in this section I am going to explain how you can print in AutoCAD I know there are a lot of people struggle with this topic as it’s a bit complex but I will explain the most important tips to make it as simple as possible first of all look at the tabs located here the first one that says model is where we can make all the project this workspace seems to have an infinite area so we can make the drawings that we want but of course the larger the file the slower the computer gets the tabs that say layout are used for printing I’m going to layout one here there is a paper with a specific size and these drawings is what we it would be printed to print properly we should specify the paper size that we need I am going to click here with the right button and then click on page setup manager in this window I choose layout 1 and click on modify so here you have the page setup first we should choose the printer by clicking on this tab if we want to save a page in PDF there are several options here regarding the file size and print quality I usually use this one DWG to PDF to change the paper size I have to click on this tab for this case I want A4 this one on drawing orientation I choose between landscape and portrait finally click OK and close to save changes now that we have the paper size we have to decide what we want to print on there on the layout tabs there are two spaces paper and model space we can switch between them here currently we are in the paper space if I play Zoom or move it works for the paper notice this rectangle here where I have the drawings it’s a viewport and it’s like an access to the project I am going to double click inside and it switches to the model space now if I zoom the paper doesn’t move just the objects that I drew as well if I draw a line here it will appear exactly in the same place in the model tab change the size of the viewport I’m going to click on model to switch to the paper space again at this moment I can select a few ports then with the grips I can modify it to cover the entire paper double click to go to the model space now I can zoom in the drawing or put a specific scale for the paper it’s here I specify for example one per 100. when I finish I am able to print the drawing click here with the right button and this time I click on plot continue to plot a single sheet here I can click on OK to print or in this case to export the file as a PDF some printing tips hide the viewport when I plot the file the viewport appears by default on the paper if you want to hide it follow the next steps go to the layer properties manager and create a new layer just for the viewport switch to the paper mode click on the viewport and move it to its own layer then go again to the layout properties and freeze the layer you can see that it’s not appearing anymore so if you save as a PDF or print the file right now the viewport is not visible have different colors on the viewport the default AutoCAD workspace uses a dark background with a reason to be better for the eyes when working for several hours because of that it is common to use light colors in our project the problem is when we switch to the layout mode the colors can be too light for a white paper for example the doors are a bit hard to see don’t worry it’s possible to set up different colors for printing first you have to double click on the viewport to switch to the model space go to the layer properties and you can see this column with the label VP color if in your version is not located next to the color tab look at the right end of this table then I’m going to change the color for the layer doors click here and put this one for example now it’s much better insert text I am going to explain to you quickly to insert text in AutoCAD it’s not hard and there are two types of text single line and multi-line text I will start with single line text first we insert the start point then this line specifies our text height I can either click or specify a distance I’m going to type 100 press enter and then I choose the direction if I want to type horizontal text I need a horizontal line now I can write anything and when I finish I click in a different place to write another text or if I don’t want more I can just press enter or Escape now let’s see the multi-line text wait the command choose first point and I specify a selection area to fit the text in but just the horizontal length the height of the rectangle doesn’t matter then I can write the text I like the single text this this time a temporary tab for editing text appears on the ribbon here I have options for editing a paragraph and much more if I want to change the height I need to select the text and change it here as you know this is very simple to write text in AutoCAD part 4. in this part I’m going to teach how to scale objects how to attach an image to the drawing and apply a scale in order to have the real dimensions how to import a PDF file and this is especially useful when the file was previously created within AutoCAD how to stretch objects and how to fill in closed areas with the command hatch of course as always I like to share some tips with you along with the explanations let’s start scale objects let’s learn how we can scale objects this command is not hard but you should understand it well if you want to use it properly to turn on the command scale click on the icon it’s this one select the objects I want to scale in this case I want to scale the figure on the right choose this base point now there are several modes to scale objects the one by default is to insert a scale factor I am going to type 2 and the lengths of all these lines changed to double size okay I’m going to repeat the process but this time I want to shrink the objects to half size I type SC to activate the command again select the objects but now I don’t select the dimension line for the scale factor I insert 0.5 and the lines were convert to half of the length that they used to have previously look that this Dimension line was updated even it was unselected scale with a reference now I’m going to show to you how to insert the scale with a reference I turn on again the command scale and select the objects select the base point looking to the command bar it says specify scale factor or these options copy and reference I’m going to use the shortcut R to use the reference and what I need to do here is draw a reference line and type a new length for it so it’s very simple I click for the first point and then I click for the second point finally I type the new length which is 55. and press enter to confirm it use scale to import a PDF or attach an image in AutoCAD it’s possible to insert an image to use as a background of a project for example images from Google Earth can be used to draw site plans to attach an image file I go to the inserts tab at the ribbon click on attach and select an image from my computer I choose this one in this window I can set few options here it’s important that I click on specify on screen the insertion point otherwise the image is inserted on the coordinates which are specified here okay except if it’s exactly what you want I click on OK and now I click for placing the image for the scale factor I’ll leave it for now press enter so what happens here most of the time that we insert an image it’s not scaled properly for example I have a reference between these two points which is approximately 206.17 meters if I use the distance command I type the I press enter I can notice that the distance here is a bit longer than what it should no problem I can use scale with reference I turn on the command scale select the image by clicking on the border if I click inside the image it doesn’t work change the mode to reference and then I draw the line between those two points I will try to make it as accurate as possible now it should be correct ah and I want to share a tip with you always try to use a long reference line because if understand my reference was a short distance after scaling the image tends to be less accurate to import a PDF file I can click on the icon also located on the search tab here I’m going to choose the file of the exercises then the window that opens has a bit more complex options than for attaching images actually this is a very useful function because if I insert a PDF that was previously created in AutoCAD I can recover all the layers and the objects as this PDF has two pages first I need to click on the one that I want to import on PDF data to import itcom Vector geometry to import the lines poly lines circles arcs and so on if I click on true type text text created with a font that has this symbol will be automatically recognized as text in AutoCAD most fonts available are to type so usually this is not a problem here the option below I click on it if I have raster images attached in this case there aren’t so I keep it unselected then on the right panel I take on the first option use PDF layers on the panel below you can find more options to add but for now let’s click on OK and I am going to insert the file on the project nice now if I go to the layer properties I can see that new layers were created from the PDF and due to the fact that I made this drawing in not a cat the layers are the same from the original DWG file I’m going to check out how the objects look like and you can see here Body Lines among other objects also look how the text was recognized if the text was not on a true type font it would be splitted in very small lines and arcs which wouldn’t be so interesting however not everything is perfect the dimension lines are not recognized neither block references which means I have to create them again but in general insert PDF can be very useful just be aware it’s only available in the versions after AutoCAD 2017. stretch objects sometimes in AutoCAD we need to stretch figures let’s learn how it works first it’s important to have in mind that this operation doesn’t work for blocks as you can see here I have only lines and polylines let’s do it I am going to click on the command stretch it’s this icon here then I have to select the parts to actually stretch so I open the selection from the right just until here that I specify this base points as you can see I’m extending and moving objects to this side and as the dementia line was in the selection it is also readjusting now I can click to place the objects exactly how it’s on the screen however it’s without any kind of precision or type a distance to extend if I type 800 actually I add that value to the original length of 600 and the total is one thousand four hundred the way that the object stretch depend only on the selection even I select a different base point the result is the same let’s repeat this again and this time I want to change the selection to cover also design I press enter and you can see the object stretching differently now I want to try to stretch vertically I select the objects press enter and oh it’s not as I was expecting but I select all the objects why does the why does this happen when I was doing the selection I kept these sides outside of the selection area and even everything was selected because the external rectangle is a polyline a single object the really important thing here is is what actually I am covering with the area Hearts filling in closed areas in this section I will be talking about a drawing tool which is used to fill in closed areas it’s the command hatch but first I am going to create a new layer in this file let’s check out if you remember how to do it I go to the properties manager click with the right button and new layer I name it as simply hatch then I’m going to choose a color for it for example this kind of pink okay now I’m going to turn on the command hatch it’s located here at the drawing panel wait a few seconds if you want to read the description of this tool sometimes it can be interesting then to apply your hats click on it and I have to click inside an enclosed area it can be any of these rectangles I click to fill this one ah it’s in a white color I forgot to change the layer yes when you create a new layer you still need to set it as the current layer before you draw the objects in otherwise it will not work go to the layer Tab and click on Hatch now I see this message appeared the current layer will be turned off what do you want to do for any reason this bulb is Switched Off and if I draw objects on that layer they will not be visible click to turn it on I’m going to repeat the process click on the command hatch and fill that area now it’s on the correct layer press enter to confirm then by dragging the mouse over you can see that it’s a hatch object now I will show you another way to use hatch I click again here and then instead of pressing enter I feel a different area right away what happened is that both areas are now a single object hot editor above a new tab appeared at a ribbon specialized for editing hatches I’m going to show you briefly the functions here I’m going to click on this button at this panel and you can see a lot of patterns to use here the first one solid is the simplest one it fills the area with just one color I chose for example this now let’s have a look at the options at this side on these controls I change the scale look how is the effect on the angle tab above I can rotate the pattern finally on Hatch transparency I add a transparent effect to the objects I want to mention one thing when I first tried to change the scale by clicking on the controls I realized that these values didn’t change a lot even if I type a number with decimals it shows just zero when this happens it means that I should go to the unit properties type un and press enter and in this tab I need to set decimals for example two decimal cases then it should work fine part five how to use array with the command array we can copy objects arranged in a pattern there are three different modes rectangular array polar array and path array I start with rectangular array and for that I just need to click on the button that’s the mode set by default then I’m going to select these objects and press enter so an array was generated and a special tab on the ribbon has appeared now I can edit this pattern as I wish here I can set the number of columns and rows if I decrease the number of columns for example from 4 to 3 as you can see on the screen the last column is suppressed the array creation I find it very intuitive and I think it’s easy to understand the options here while looking to these little drawings there the distance between is the distance from the origin to the beginning of the next element the distance total is from the origin toward the last element starts simple I’m going to change the distance between rows to 200. and look how the pattern moves of course the total distance was updated in order to match to the new distance between lines to exit the array mode I press Escape now if I want to confirm the distances I can use the measure tool or type Di and press enter notice that the vertical length between two elements matches as well as the horizontal length grapes in an array object whenever I select an array you can see the dynamic grips the blue buttons here which I can use them to modify this array for example if I click on this one on the second row I can change the vertical distance between two objects for that I simply type the new length to change the horizontal length on the other hand click on this one if I click on the grid button last row I can add more for example 7. if I click on this side it’s the numbering of columns that I can change the grip on the opposite corner changes both rows or columns by dragging the mouse basically these operations can also be performed on the array tab but sometimes it’s just more practical with these buttons another useful thing in Array is changing the base point I click on this icon set the new point for example or on the corner and the grips moved with the base point but they perform exactly the same actions let’s make a polar array I’m going to draw a small circle with its center located at the boundary of this big one on this side now I can click on the command polar array it’s this one there basically what I want is to have this object displayed around I click on it then the center point of array is going to be the center of the bigger Circle and that’s the result the program sets 6 circles around by default but like for the rectangular array I can edit this on the top of the ribbon so the array tab for Polar array is a bit different especially the panel items on the first parameter I set the number of items in this case I specify 18 and they cover all the circumference because I have 360 degrees for the fill parameter in between I specify the angle between two items and in this case it’s 20 degrees if I try to change the angle to 30 you can notice that it doesn’t work because it’s not possible to fit 18 items with that spacement let’s try 15 degrees so what happened here in order to keep 18 items the angle on fill was updated now it’s only 255. grips and polar array and tips the small square on the original item allows me to change the radius of the array I’m going to set for example 50. and this is how it looks like the grip on the center can be used to change the position of the array on the other hand if I click on this little arrow I change the angle between two items let’s suppose I want six items the angle to have then distributed equally is 60 degrees however it’s possible to increase a bit that angle but the last and first item we stay closer than the others path array the third array mode available in AutoCAD is path array we can copy objects along a line or a curve let’s see how it is first I’m going to draw a spline which is a smooth curve I click on the command located here spline fit and I can draw a curve by specifying some points on spline fit the curve crosses exactly the points that I insert when I finish I press enter here by pressing escape and Stat it cancels the command it will not work next I draw a rectangle on the first endpoint of the spline now let’s use the path array I click on the icon select the object to copy press enter and then I select my path so I have made it however probably I want to edit the spaceman position a rotation at the command bar you can easily check out that there are several options to edit let’s analyze some of them base point the base point will be exactly at the start of the path I click on the option then I change for example the base point to the opposite corner and that is the result the objects moved but without rotating tangent Direction this one is useful if I want for example to have one of the rectangle edges tangent with the Curve I’m going to click on the button tangent Direction then just specify two points and the objects will rotate but now suppose that I want a path to cross the center of the objects I’m going to use the option base point and click on the center of the rectangles hmm But it’s not snapping to the center point if this happens to you it means that you should turn on the mode geometrical Center in object snap it’s this one now it’s going to appear I just need to have the boundary first and click on the center array tab on the ribbon the tab on the ribbon is now specific for path arrays specially the first panel I can change here easily the spacing between total spacing and number of items I think the best way to absorb these things is to Simply practice you can play around with all these options and after a while it will be easier for you explode objects once I create an array all the group is considered a single object now imagine that I want to get rid of the array it doesn’t work with just select it and press delete it erases the the old thing as you see what I need is the command explode it basically returns a compound object to its original components it’s very easy to use this I click on the command explode select the array and press enter as you see all these are now separate polylines then I can manipulate the objects as my preference consequently I can explode the polyline in separate lines another way to use explode is on blocks hatches and other kind of objects but some of them it doesn’t work like text utilities panel let’s talk about the utilities panel and I’m going to start with the measure tool there are several ways of measuring as you can see here I start showing you the first one quick measure which is the one set by default when you click on this button for the first time when I move the mouse over the objects some Dimensions appear on the screen and these yellow lines measure vertical and horizontal distances between the closer objects on the other hand if I try to check the dimensions in a circle at the first time it looks a bit confusing all these values here but they just showed the radius of the circle they indicate for example 100 is the radius of the bigger Circle as well as 15 is the radius of the small circle the yellow lines don’t measure anything here just don’t care about them honestly this quick measure it’s not my favorite because even it’s true that we can have a lot of information at the same time it can be a bit confusing but of course that is just a personal taste TI can distance I use it a lot as I find it very intuitive it simply measures the linear distance between two points another one which is very easy to use is radius I only need to click on a circle to check it out measure an angle this one is simple I can select two lines to measure the angle between them or I can check out the angle of an arc by clicking on it now let’s go to where I was before I want to focus on something when I select the objects to measure the angle this menu appears where I can choose from different types of measures I’m going to click on for example area and with this I can measure the area of the triangle it’s very simple I just need to click on all the vertices and press enter at the end then you can see in this box the area and the perimeter but how could I measure the area of a circus since it doesn’t have corners I click on the icon then at the command bar I can switch to object I type O and press enter finally I just select the circle quick select on the utilities panel you can find other tools at a small icons at the right the first one above is quick select if I click there I open this window where I can select objects by using filters for example I can specify a type of object or select by color now I will select all the objects with color cyan click on OK and here it is this is the only one in this color other options can be select all the objects of a specific layer or you can select by line type among other options if I click on this icon I select all the objects in the workspace except the ones that are frozen or unlocked layers the button below is the quick calculator actually it’s a kind of scientific calculator and there we can do from basic calculations to a bit more complex ones part 6 the final part dimension lines now I am going to teach you how to draw dimension lines this is a classic feature for annotation in your drawings in this video you can see the dimension lines indicating its distances now to draw dimension lines there is a panel on the Home tab here or if we go to The annotation tab we can have all the tools so there are several types of dimension lines whose you can find them by clicking on this Arrow for now let’s start with the most common one linear dimension to insert the dimension line I just click on two points then I click again to put the dimension line on the place that I want so it’s very simple however this feature is quite complex and we usually have to set up some settings sometimes the dimension lines are not proportional with the sizes of the objects that they measure so I’m going to open the dimension style manager by clicking on this little arrow here I need to choose the dimension style that I want to edit I select standard which is the current one and I click on modify now there are loads of options here but for a beginner the most important is the size of the text and arrows as well as the units go to symbols and arrows tab look for Arrow size and put a value that seems convenient then the size of the text can be changed in the text tab as you see both sizes have a height of 2. to confirm this I can always measure the distance here you can see it’s too on primary units tab I can edit the unit format the number of decimals let’s change it to 2. and I can add a prefix or a suffix for example suppose that the units here are emitters I can type the symbol m on suffixed to appear after the values like this other types of dimension lines as I showed in the beginning there are more types of dimension lines to use in AutoCAD depending on what we want to measure for example let’s measure using the linear Dimension the distance between this point and this one as you see it’s measuring either the horizontal distance or the vertical one if I move the pointer this way but this is all fine because I can insert an align dimension with this option I can measure objects that are not located in the Cartesian axis so it’s much better as you see angular Dimension now I am going to click on the angular Dimension this one is still simple to use I can measure an angle by clicking in two lines that intersect each other the angle itself I can place in any of the four sides of the intersection plane radius to measure the radius of a circle first I’m going to draw one here then I choose the option to measure the radius and just click on the circle I click again to place the dimension line in this tutorial I want to show you also the arc length I can measure the distance of an arc and yes this only works on arcs if I try to measure the perimeter of a circle nothing happens as you see apart from those Styles there is the automated Dimension which is the icon here it detects automatically what is the most suitable type of dimension in each situation for example if I hope this line This Square appears and I can click on it and I will place the dimension of the length of this line I can do the same for the other lines as you see for measuring an angle I have to choose the option angular and then I can place it like I did previously in a circle the automated Dimension places the diameter by default however I can change to place the radius instead now let’s see some tips and peculiarities dim layer on this tab at the panel Dimensions I set the layer where I want the dimension lines in I choose the layer Dimensions as I created this specially form placing the dimension lines however if I switch to the Home tab the current layer is lines and if I draw Dimension line you can see that it goes automatically to the dimension layer snaps on arrows in some versions of AutoCAD like the one that I’m using the system snaps to the end points midpoints geometrical centers on the Arrow shape and this is a bit annoying because usually I only want to snap to the end of the dimension line this point and honestly I haven’t figured out yet if there is a way to get rid of those snaps if anyone knows it’s welcome to post a comment on this video it would help a lot of people however I’m going to share with you a good way to deal with this on symbols and arrows tab at the dimension style manager click on the first Arrowhead and as you can see on this list there are plenty of them to use but for now I choose known automatically the second Arrowhead is updated to match the first one the result is this it’s easier to snap to the end point Additionally the distances extend beyond dimension lines and offset from origin are these ones that I show on the drawing put 0 for both and it’s even better I can only snap to the intersection of the line below and to the dimension line end basically you can make all your projects with these settings and just edit the style according to your preferences when you finish the dimensions will be all updated choose the style of Dimension line before drawing whenever we draw a dimension line we should make sure that the desired Dimension style is active for example I’m going to switch to annotative and as you see the settings there are different another thing what I have been teaching during this tutorial are the standard dimension lines all the sizes that we set on the dimension style manager are according to the workspace the annotative dimensions are the Styles which are represented with this icon here the sizes that we set are according to the real size of the dimension lines on the paper that we print however the annotative dimensions is a subject that you will find on a second tutorial which is going to start right away foreign now we are ready to start getting deeper into the program here you will learn very useful tips to improve the knowledge you have already learned here now this tutorial is divided in five parts and you can check them out in the description of the video Let’s Start part one let’s have a look at the contents organize your working area we can save amounts of time if things are prepared in advance annotative objects by using annotative Dimensions text or blocks you can have those kind of objects with a specific size when you print your files even if you have different scales on your viewports in the layout and finally you will learn to use the zoom command instead of just scrolling the mouse wheel this is especially useful for large files as there are functionalities to zoom specific areas instead of being looking for a specific element forages tips for having a good organization and save time for me it’s a very important thing as with spending a couple of hours organizing your layouts and creating personalized templates you will save a lot of time in the future whenever you start a new project save space when using two screens if you have two screens on your computer you can use them as your benefit when working on AutoCAD as you may be familiar sometimes we have to open the layer properties panel or open the external references palette as well as the properties window all are using space on your screen but however if you have a second screen you can play stare at the palettes you often need in AutoCAD for example here I place these ones in a way that I can use them easily all the time and this is important the palettes are still on the same position if you open another file or if you close the AutoCAD program and come back just tomorrow the things will look more organized which is more pleasant to work create a personalized template for your projects let’s suppose you need to create architecture projects often and you need floor plan drawings elevations or location plans in addition the scale and the paper size you use most of the time is the same so if that is your case one good way to save time is create a personalized template with everything already set up for example look to this file where I draw this floor plan the layers that I use here probably will be the same or similar in other projects so first I can empty the workspace make sure that all layers are turned on and unlocked then go to select all and press delete now I can save this as a template or saving as a normal DWG file would work fine it’s important that you choose a name that you will remember for example project architecture okay I can continue personalizing this file for example editor units and precision if I often use the same units in my projects on the layout tabs I can save loads of time if I have several tabs for floor plans elevations sections and so on I can go to the page setup manager to set the paper size for example A3 and also the printer if it’s the same all the time then I can delete the objects here by selecting all make sure I am on the paper space now I’m going to add a new layer called title block and I’m going to draw on the paper a title that can be used on all my drawings as soon as I finish the title block I can create a viewport in this layout I go to the layout tab then I click here to insert a rectangular viewport and draw it on the paper after I double click inside to switch to the model space and set up a scale for it ok suppose that most of the time I use the scale of 1 per 50. I click on it so I don’t need to set it all the time when I start a new project then I can rename this layout to ground floor I double click on it and I type the name that I want then to create similar layouts I can right click here then move or copy I select ground floor and tick create a copy then I click on OK and a new tab with the same configuration was created so in a project architecture I can have all these steps for floor plans elevations site plans or location plans and when I’m happy with the template I can save it in my computer on save as click on drawing template and save it with the name that you like I can add a description here also and click on OK basically with this I can save a lot of time when I start a new project annotation in AutoCAD in the next part we will focus how to insert annotative text and dimensions it’s simple we just need to play a bit with scales in the workspace the text height that we insert for our text is actually the real size that will be printed for example in layout 1 I want to write text in this viewport with a text height of 0.005 meters the proceedment first check out the scale of the viewports double click inside here and I can see it as 1 per 200. then switch to the model tab on the Home tab go to The annotation panel click on this arrow and switch the first tab to a notative or to a style that has this icon associated change the scale to fit a viewport scale I click on one per 200. create a single line text here the command is up there click for the base point and when you are prompt to insert the height it says here specify paper height I am going to type 0.005 because in this drawing I’m using meters as units type the text and click in a different place then switch again to layout 1 and here you have the text if you print it and check it with the rule it has to measure five millimeters now let’s go to another layouts tab this one this time I want to add a text to the viewport where I have the door the scale here is 1 per 16. so going back to the model space let’s find the door I’m going to switch the scale to 1 per 16 and let’s draw another text this time for the paper height I type 0.01 one centimeter finally I type the text when I switch again to the details tab I can see the text there annotative Dimensions this uses a similar logic as annotative text we want to add this Dimension line with the same five millimeters of text height on the paper go back to the model space first change the current layer to dimensions then click on the Arrow at The annotation panel and then click on the second tab which is the one for dimensions choose an annotative style this one now we have to do a different step we should edit the dimension style first click on this button in this window choose annotative meters and click on modify here I go to the label text and specify 0.005 for the text height then in symbols and errors I can put the same measurement for the arrow line finally I click on OK and close to add the dimension line I change the scale again to fit the viewport scale of 1.200 click on this icon to draw a dimension line and I’m going to place it here when I finish I can go to the layouts tab and here you have the dimension line okay it’s too light in a white paper that’s no problem I can click inside the viewport go to the layer properties and then in Dimensions I can change the viewport color to a darker one now it’s much better annotative blocks now let’s check out how we can create annotative blocks they can be useful for some kind of projects where we add symbols that can represent elements for example here suppose we want to add a socket to this project as it’s a small element to be seen in the plan we usually represent it as a symbol with a fixed size in order to be easily seen in drawings with different scales in the example here the socket has five millimeters of diameter in the paper back on the model space I’m going to zoom in the object and the first thing I have to to confirm it has the size that I desire oh and don’t forget to set the scale as one per one because we are drawing an annotative element otherwise the block will be automatically scaled after being created and I don’t think that’s what we want so as I want this distance as five millimeters you can see that it’s not I have to use the command scale so I type SC lect all the objects press enter I can choose this one as the base point and then instead of a scale factor I have to choose a reference then I select two points for my reference line and then I specify the new length as 5 millimeters oh and just to let you know in this project the unit is millimeter now that our symbol is in the correct scale I’m going to convert it to a block I select all the objects and make sure they are on the layer 0. to create a block I can use the Alias B to open the block definition to create a block I type the name for the block for example socket then we need to tick this box that says annotative I click on OK and I can choose the base point and the block is finally done the next step is to insert a block on the drawing but in the scale of one of the viewports it can be one per 50 one per 100 or 1 per 200th as you can see there I decide to choose one per 50. so on the model space change the scale here to 150. go to insert block choose the socket and I’m going to place it where it belongs I hope this end point and put it there if you go again to the layout mode you can see it on the viewport with scale 1 per 50. so until here everything is correct then how can I add the other scales if I access the properties of this block I can see under miscellaneous that this object is annotative along with the annotative scale however I can easily add more scales here by just clicking on the button at the right this is The annotation object scale and I click on it to add more scales I choose 1 part 101 per 200 in this list I clicking OK and here you have them then it should be done so let’s change the scale here and you can see that the object is resized what happened is that this block has now three different scales when you look at the viewports the socket symbol has exactly the same size in all of them and then if you print you will notice that the symbol measures exactly five millimeters of width going back to the mother space and select the socket you can see the three scales when you have this button on the status bar turned on then let’s put it just in another color to be easier to distinguish Zoom now I’m going to talk a bit about zooming in AutoCAD as you know the most simple way of zooming and the most common one is to scroll the mouse wheel to reach the different parts of our project however for large projects this can be a bit annoying to try to find specific areas for that reason there is the command Zoom let’s have a look at it I type that and press enter then if you look at the command bar you can see several ways to use the zoom the option by default is drawing a window on the workspace for example if I want to show the starkey’s division here I draw a window covering that part and here is the result so I find this specially useful when I want to focus something specific as the zooming is more precise in this area another way of using Zoom is using the option all this sets the zoom to cover all the drawing in this file including the position of the UCS coordinates in the corner here then a similar option is the zoom extends very useful by the way I use it quite a lot it shows all the objects covering the full screen here the difference regarding Zoom all is that the position of the UCS coordinates can be hidden if I click on Center I pick a point to be placed in the center of the screen then I specify the zoom height by drawing a line here simple now I’m going to show you something useful for larger projects in this file you can see all these drawings of a single architecture project in this case it’s an exposition Center there are floor plans sections elevations site plans and so on these controls at the top left corner click on this one that says stop and here you can switch to a different view of the workspace however the ones here are useful when I have 3D drawings look that I can’t see anything interesting when I switch to the left or right views this is because everything in this project is two-dimensional and was created in the top plane on the V Cube you can understand a bit better the location of the views by default especially when you click in a corner to switch to another isometric View okay but what I want to do now is actually create a custom view to show up a specific part let’s go to one of the floor plans located here and to be more precise I zoom with window okay now it’s better then I go again to top and this time I click on view manager I’m going to create a new view here on new and first I need to choose the name it’s going to be a schema the installation sanitarius yes it’s Spanish but it means literally sanitary facility scheme then I can put it into a category it’s empty so I can create a new one let’s name it floor plans The View type I keep it still I don’t change it for the boundary I choose the current display and click ok to close here okay again and then I go back to top and on custom views I choose the one I just created and you can see it zooming automatically okay it’s true that this floor plan was not very difficult to find however if you are working in a huge project with loads of drawings sometimes you can stay looking for a specific detail for ages like those books where you need to find Waldo so now we want to zoom up to these objects but this time let’s do it a bit different go again to the view manager create a new view called detail one and put it into a new category details and in boundary this time I’m going to define a view window I click in this button then I search for the part that I want I told you it’s hard where are they ah here so make a window in the place where I want to zoom I press enter when I’m ready and you can see a preview on The View manager I click ok to confirm it and close so for the next time I want to go to the detailed one it’s much faster Charan [Music] part two layout tabs extra tips when we set a viewport to show a specific drawing with a specific scale we realize that in a small destruction we scroll the mouse wheel and it messes up all the scale and then I have to go to the scale list and click again in this case in one per 150. however there is a very useful tool here I can lock the viewport by clicking on this icon now even I am in the model space I can zoom or move in the same way as I was in the paper mode by the way I can still draw or erase objects inside the viewport so I just recommend you to lock all the viewports when you don’t want to change them anymore write text and draw the title block on the paper when you need to add text to your papers just draw it directly in the paper mode I mean outside of any viewport it’s easier and more practical first it’s text that we don’t want to model as it’s unused for annotation second the size that we specify is the paper height in this case 5 millimeters and I don’t have to scale it like in a model space much easier the same applies for the title block just draw it on the paper you can start drawing the borders then the text using the paper height in this case after placing the first single line text I want four of these with the same spacing I can use here the command copy then the option array I Type 4 and finally you can click again to confirm the position or insert a specific distance between objects and then just change the names to the right ones okay I can take the opportunity to explain to insert an image to the layout for example if you want to add a logo of your company there it’s quite simple go to the inserts tab then click on attach and select an image to import to this file I select the cutting black logo for example just to show you how it works we can insert the coordinates of the insertion point or specify it on screen and that’s what I’m going to do click on OK place the start point I can click around here then it looks like that image is a bit large but that’s fine just press enter for now as we can scale it after with the reference use the command scale select the image click for the base point choose the option reference at the command bar and then chose two points of a reference line to resize it and this time I will not insert any length because I don’t know it I just move the cursor in this direction and you can see a dynamic preview of the logo as soon as it looks great I can click to place it there so simple isn’t it yes let’s continue now we are going to learn to add more viewports on the same paper usually the purpose of doing this is to show different drawings or a specific detail that we want to show on a smaller scale let’s go to the layout tab on the ribbon here we will create a new viewport by clicking in this icon and there are three ways rectangular polygonal and object let’s go for rectangular so I simply draw a rectangle here then I double click inside it to switch to the model space this time we will use a custom view that we created in the previous chapter I click on top go to custom model view and choose detailed one and look how useful this can be not need to search for that part so easy next I go to the scale list and I need to choose one one per 50 and the reason that I decided to use this scale is because one per 50 is the same as 0.02 which is relatively close to the value that I’ve got here and you can see that the drawing didn’t change that much double-click to switch to the paper space and readjust the viewport by clicking on the group stair ah and don’t forget to lock the viewport to not move it again after I can copy this text and place it below our new viewport select the text I’m going to use this endpoint as my base point and then click in this corner for the second point to keep the same spacing towards the viewport and rename it with the correct text put also the scale of 150. then let’s draw a circle here the radius doesn’t need to be precise on the layouts tab choose now the option to create a viewport from an existing object this one then click on the circle to convert it to a viewport and of course this option only works for enclosed areas then suppose what I want here is to zoom this specific part move the circle to a specific layer if you want or put the object just in a specific color and then I can draw a small circle in the same place of the floor plan to indicate that this area belongs there and if you want at the end you can connect it with lines other drafting techniques in this chapter I’m going to talk about drawing tips and I will start with the grid and snap modes grid and snap mode can be useful when we have to make detailed drawings especially when they have regular shapes let’s have a look at them the first icon at the status bar enables the grid as you can see here try it on your computer however you will probably notice that it looks darker than here if you have the default colors for me they are a bit hard to see and that’s why I prefer to change them but okay this I will explain to you at the end of this chapter for now let’s Zoom a bit and activate the drawing command for example line you can see that the cursor doesn’t snap to any point because the snap mode is off let’s turn it on and now yes you can click on an intersection of the grid line so it’s easily understandable that these tools work together and there is no point to turn on the snap mode if your grid mode is off now I’m going to click on an intersection of two major lines and by moving the cursor you can understand what is the length between two points of the Grid it’s 10 and the distance of two major lines is 50 because is equal to five minor lines so as you can see this is quite simple now have a look to this drawing we can easily guess the distance between some points if they are not that far away for example this distance is 100 millimeters and the width of the rectangle is 200. because there are four big squares 5 10 15 20 you can just count them so to draw that rectangle with the grid is actually easy this is the first corner then the opposite will be four large squares to the left and one above the line at the bottom so click there you can zoom a bit to make sure that you click on the correct point it’s better okay now let’s learn to edit the snap and grid spacing click on Snap settings to modify those values it’s in the first step of the drawing settings window here of course to snap only in every point of the grid the snap spacing and grid spacing must match don’t forget this and the values that I have now are the settings that I used in the previous example suppose we set 5 for SNAP spacing but leave 10 millimeters for the grid spacing the result is this and it can actually be a good method because with the same grid I can have the center of each Square as an extra point to snap as you can see to have a different X and Y spacing I need to uncheck equal X and Y spacing and then I set the values here I have 5 millimeters for y distance and 10 for the X distance I can also change the length of the major lines the higher the value the easier to measure larger distances if I’m zooming out the workspace at one point the Grid resizes in a way that the lines won’t get that close we couldn’t see anything if that would happen this means that at this moment the spacing here is not what we put on the settings be careful don’t draw anything now always draw in the maximum zoom and in the case that you want to Draw Bigger objects simple just change the spacing settings to bigger values if I like to have the workspace more organized and I want a point to be in the corner of an intersection when I zoom out a lot like where I am now simple place the cursor there the corner and zoom in slowly keeping the cursor in the same position one degree doesn’t resize anymore it means that the grid is now resized correctly change the grid colors as I told you previously the default grid colors are dark but I understand their points we don’t want the workspace to look a mess with the Grid on especially when we have lots of layers with different colors like in the example here but I think that putting the grid a bit lighter it doesn’t interfere that much so let’s learn to do it to edit the colors we have to access the options menu then I go to the display tab and click on this button that says colors here we can change the color of each element on the workspace you can see a big list here also they are grouped by context it’s the list on the left now it says that we are at a 2d model space so I am happy with most of the AutoCAD interface colors so I don’t need to change them except the grid which is a bit dark for me to change the color click on the element go to color choose one from the list or click here to pick a different one let’s say I want it a bit green but in a gray style I keep the cursor here and then I drag this rectangle to choose the proper color a bit up to be more visible and click on OK it’s done now I need to change the grid minor lines to do it I choose the same color then I click again and pick up a color so the cursor will be in the same position this is good if you just want to change the color a bit and do not look very different so I want to put the selector a bit darker then click on OK I apply in close the window and now it looks more visible so you can just choose a color that will be comfortable for you change the position of the UCS look to this situation here I want to draw these objects in reference to the diagonal wall it would be hard to draw them accurately if I use the UCS coordinates on the position by default you can see that while I’m trying to draw that line I don’t have any reference to draw it perpendicular to the wall but no problem because I can make the things easier by just rotating the UCS coordinates I go to the icon click on it I place it in this corner and then clicking on the x-axis I align it to this diagonal line then I can switch to also mode and you can see that I can easily draw vertical and horizontal lines according to the new UCS position also if I want to insert a block now it automatically rotates and the same happens with the grid then to restore the original UCS which is the WCS World coordinate system just click on the icon and then select word now let’s have a look at the shortcut menu the one that we can open with the right button of the mouse actually most of these functions are icons located on panels in the ribbon but sometimes it can be easier for us doing this way now I will make a quick introduction of what you can find here the first option of there repeats the last command used it’s an alternative way of just pressing enter when we don’t have any command active I actually prefer to just press enter it’s much easier then there is a list of the last comments used on the clipboard we find the basic tools to copy move or cut objects to a different file and this still works by just pressing the classic shortcuts like the Ctrl C Ctrl V and so on for example I will copy these objects press enter then I go to a different file and just click on paste and they will be copied exactly in the same position as they were before but if you wanted to copy this door straight you can use the method that I just showed you previously by moving the UCS coordinates to the corner then rotate the x-axis in line of the edge of the door and repeat the process press Ctrl C and then paste it in the other drawing and now it’s straight back in the shortcut menu I want to show you some options that I use quite often like isolate objects I’m going to select this part and then I click on isolate objects and you notice that all the other drawings disappeared to revert these changes just click on ADD object isolation in the same Sub menu there is also height objects which will be the opposite if there are parts that you are not using at the moment you can hide them temporarily a bit down in the list there are the options to use the pen Zoom or the steering wheels then there is the quick select quick calculator also available on the ribbon and the options menu also don’t forget that when you select objects that menu is different and Depends the kind of object that you select for example in a block you get options to editor block reset a block if you modify it or edit a block in place if you don’t want to open the block editor then you find the basic commands to modify objects so it’s also possible to access them from this list then there is the draw order and this one I use a lot when you create a new layer AutoCAD puts the objects of that layer above everything that was created before for example here I created the layer for the dimension lines I after the layer for the walls and because I don’t like this extension lines above the walls let’s sweep the order and for that I need to select all the objects of the layer dimensions and I can do it from the quick select choose the layer DLI and click ok now that auto dimensions are selected I can go again to the right click menu go to draw order and choose send to back and look that the walls are now visible when they overlap dimensions another tool I sometimes use is group objects let’s say I want to group this floor plan but without the dimensions turn off the layer DLI then I select everything and from the menu choose group and I could move or copy this house elevation to a different place the option select similar is also very useful by clicking on a type of object for example a dimension line you can see that it selects all the remaining Dimensions but yes they must be located in the same layer for example in this situation the large Dimension is not selected object snap overwrites has a useful tool that not a lot of people know suppose we are drawing a line here and we want to connect it perpendicular with the diagonal line below as you see it’s only showing up the midpoint and the end point but if I click with the right button I can see object snap overrides I go there and I can choose a different mode in this case I click on perpendicular and now you can see the symbol appearing just click on it to make those lines orthogonal twitch other you can try the other modes by yourself for example nearest or on the top you can create a temporary track point or choose the middle between two points this is how it works I choose two points and it selects the middle distance between them so just explore the other modes maybe you find some useful for you as long as the other options from the shortcut menu [Music] part three attributes in blocks to Define an attribute we can either click on this icon at the Home tab or in the insert tab you can find it located in the block definition panel click on it and the attribute definition window shows up on the screen then there are three main fields to fill for each attribute first we insert the tag which is just used to indicate the position of the attribute this text appears in capitals and you can’t put spaces between characters so remember this below you should type The Prompt sentence for example if I want to fill with the name of the client I type client name on default I will put a value that will appear anytime that I insert that attribute personally I prefer to keep this empty except it’s an attribute that uses the same text often however let’s insert a value here under text settings it has the justification on the left and standard textile Below on text height I specify the same as the existing text it was 3 and remember it’s the paper height so I don’t put the tick in annotative we click on OK and we can specify the start point for our attribute so now I can draw the next one which I can repeat the process or I could use a quicker way with the command copy I use the option array with four number of items it’s exactly what I did before then click here approximately to be in line with the text at the left there are no object snap points for text objects however if you want to put the text perfectly in line there are ways to do it but it’s something that we will learn later don’t worry then double click on the second tag and this window shows up to modify the information that I had given before when you are ready click ok and do the same for the others for the scale and date I do the same in the attribute definition but here the text height will be 2. click OK and place the attribute where I want to show the scale then copy it below to make an attribute for the date and change the values okay now that the attributes are completed it’s time to create a block with the title block and the attributes first I need to switch to the layer 0. now I’m going to create a block and first I have to choose the name for the title I put tighter block A2 so I know I have to use this block in an A2 paper you can also create another title blocks for different papers click ok to select the objects and now I have two options or I select all the attributes first and then the remaining objects or the inverse first the normal objects and after the attributes I decide to select first the attributes but I still need to click on them in the order that I want to display this is important now I select the remaining objects I can cover all with the selection area and don’t worry that the attributes are inside because they are already selected I press enter to return to the block definition window click ok and the window to edit the attributes is now on the screen and you can see them on the order that I choose and now have a look to the window on the left is what I insert for the prompts the valve is at the right are what I set for the default values as you remember I put some values there but actually it was for you to have a look at the appearance of this actually it would be better to not write anything on the default because now I need to erase those blanks so let’s fill with the content that I need click ok and you can see how the attributes are automatically displayed on the Block then in this case the drawing name is too long to fit on the box so if I double click on the Block itself I can edit each attribute and in this window you can see that aside from the attribute values I can also change text options and properties just look at the tops here above so I changed the drawing to ground floor plan now let’s have a look at this example in this level point I want to put an attribute to indicate the elevation of a specific area of a plan but this time I want to place the text at a certain position and for that we have to draw temporary lines as reference so I’m going to offset this line above to 100 millimeters then let’s add an attribute here click on the icon then on the blanks put the tag level next I’m going to type insert level for the prompt and don’t write anything on default just leave it empty on the text settings change the justification to right you will see after and set the text height as 300. I do this because now we are at a motor space and it will be basically the triple of the distance between both horizontal lines click on OK now I’m going to put the attribute in this corner and you can see it aligned to the right like this exactly so you can notice when you do this way you put the text at a precise location so I can now delete the extra line and I’m going to use the command hatch let’s see if you remember it type h and press enter then I go up here and select solid change the color of the hatch to by block as we are going to make a block of all these objects to later edit the color of the hatch if we need then click on these two quarter parts of the circle press enter to finish now I’m going to convert this to a block click on create a block then type the name level point select the objects first I click on the attribute then on the remaining objects press enter again click on OK select the base point and finally it asks to edit the only attribute that this block has I type plus 1.2 and click on OK and you can see the block updated now I can change to the layer that I want and the colors of the hatch objects as I said before as by block they get the colors that I specify here at the object’s color how to edit an attribute in a block when I double click in a block reference I can edit the attributes but be aware that this only applies to that object so on text options I change the height to 200 and you can see that it updates the size of the level number however if I insert another block reference of the same block let’s put here 0 for example you can see that it still keeps the previous text height so how could I edit the attribute inside the Block in a way it would update all the block references it’s like this go to the block attribute manager which is the icon located here then in this window I need to select the attribute I want to modify and as you can see they are grouped by blocks I click on the level attribute go to edit and any change that I made here applies to all the block references so if I change the text to 200 you can see that it applies to all Dynamic blocks this is a block reference of a window projection in a floor plan if I click on it I can see the base point along with other groups created by me the one at the right is an added parameter to change the length it’s very useful because now I just type the value for a new length when I double click to edit the block I can see that there is this symbol here meaning that the block is dynamic in another words it has parameters with actions associated so let’s start from the beginning for adding a new parameter we need to use the block authorities palette if you can see it on the screen you can enable it in this button here I’m going to use a linear parameter for a distance I click in the start point and then on the end point this Distance by itself doesn’t do anything because I need to set an action and as what I want to do here is stretching the window I’m going to use stretch first I need to select the parameter then the action point this one I specify the stretch frame it’s the area that I want to stretch then I select the objects press enter I close the block and save changes and now you can see how I can change the length it’s simple so it’s recommended to select the action on the other side of the base Point otherwise they would overlap each other let’s go to the next example here I’m going to show you another parameter flip and that’s what I have in this door I can flip the opening by just clicking these buttons open the block editor and then I’m going to start with this one in the middle foreign and the reflection line will be in the middle distance between frames I could draw a line here to use the midpoint but let’s do something we learned earlier in this tutorial the click with the right button go to object snap overrides and then click on meet between two points select these two and then I can make the vertical reflection line here then I need an action to that parameter and instead of going to the actions tab I can also click in the exclamation point to add an action and then for the objects I select the line and the arc so if I close the block editor I can see the result then let’s add another flip but this time to switch the door down here this time I go to action I click on flip select the flip State tool this time I need to select everything and if I close the block you can see I have a new flip to the other side in this door there is also a stretch action to adapt the frame to different wall widths so let’s edit it’s again the linear parameter choose the two points of the dimension line then double click in this yellow symbol remember that when it shows up on the screen it means there are no actions Associated yet there are four possibilities to linear parameters so we add the stretch then select the stretch frame and I need to cover all this part and for the objects I select those here and also at the left I press enter then I have to close the block editor and you can see again the result of stretching a part of a block the parameter alignment this parameter can be useful to align the block along a line for example for electrical circuits we want to align a socket automatically along a polyline so let’s see and this parameter is actually very simple we click on alignment set the base point of alignment which I want you to be here in the middle then I need the direction of alignment which is along this direction close the block to return to the main workspace then select the socket click on the alignment point which is easy to recognize as it has a different shape and move it to the polyline simple then there are some important tips you should know I recommend you to have the mode nearest active so you can put the Block in any position of the polyline if your object snap is off the alignment will not work another tip is that the alignment will be to the other side of where you have the pointer for example if the pointer is just a little bit above the line the alignment faces down however if you have the pointer down the line the block is placed on the other side I know that this is a bit tricky but for that reason we can also add flip states to the block to switch the direction easily but as we all already know the things are never perfect in AutoCAD at least that’s our beliefs especially when the things are not working as we desire for example if you have text in a block and then you want to align it here it’s alright but if it aligns to the opposite direction you notice that everything is flipped over including the text so in the case you want the socket to face the inner side of the polyline the best is to place the Block in this side and then use the grip to flip the direction yes but make sure you don’t have the system variable to mirror the text active I mean if you type mirror text in the command line you can switch to one and then the text is also mirrored basically if you don’t want to mirror text keep it zero visibility this parameter is used to make variations on objects in a block and then display a list with different options to choose I show to you this socket as an example so I’m going to convert the switch 2 to a block uh and first I’m going to draw a line here to use the midpoint as my base point then I turn on the command block choose a name select the objects except the line I have just drawn and finally specify the base point so I converted the switch to to a block now let’s go to the block editor and here I’m going to add a visibility parameter I can just put it wherever I want because its location doesn’t affect the performance of the objects also the visibility works with visibility states which is a bit different than for the other parameters if I double click here it opens the window to manage those States I can also access it in this button at a visibility panel let’s continue first I can rename this current visibility State type socket 1. then let’s create a new one socket 2 and click on OK close the window you can see that here I have the socket 2 and as this state has exactly these objects I leave it and change it then I switch to socket 1 and here I don’t want to show up the number two click on it and then press this button at the visibility panel to make it invisible very good now I go back to the visibility State window and add a new state called socket 3. if you look at the bottom of this window there are three options here and now I take the third option and this new state will be a copy of the current status which is socket one so I’m going to add a hatch object here and first I draw a line then I activate hatch and fill all this area ah I also want to change the pattern to a solid color and then fill the area here and now that I am done I press enter important when you draw new objects here they only go to the current status for example if I switch to the socket one or socket 2 you can see that there is no hatch there on the visibility panel there is an icon it’s actually a system variable to control how the invisible objects are shown in the current mode the invisible objects are transparent so you can notice them however if you click in that button you choose to not see them [Music] part 4. in this part we will learn to use the design center as well as the tool and block palettes they are located in the view tab finally in the last minutes we will have a look at the external references a very useful feature in notacad now we can start The Design Center in AutoCAD we can import content from different drawings let’s go to the view Tab and add the palettes panel we can find this icon The Design Center I click on it and on this window we can browse for a specific twg file I’m going to choose this one and then you can see that we can have access to blocks dimension lines layers line types and other elements that are located on that file if I want to insert a specific block from this file I click here then select for example table 1 double click on it and this window appears now if I click on OK we insert the block exactly in the way that it was created but we can use few insertion options let’s see them in the middle section we have the scale and is set by default as one for each X Y and Z axis if I click on specify on screen you will see what happens AutoCAD prompts to specify the x-scale factor I’m going to type 2 and then it asks to enter a y scale factor and have in mind if it’s a different value than x that would deform the table so as I don’t want it to happen I have to use the same X scale factor 2. I press enter to place the block and as you can notice all the dimensions are now double size back on the insert window I can click on uniform scale to insert just the scale factor for all the axes so you have a step less another insertion option is rotation put a tick on there click on OK then this time I put for the scale 0.5 and then I’m going to rotate it 90 degrees on this direction so it’s simple as you see finally there is also another and important information here block unit which for this one is set as millimeters and I cannot change it as you can see actually the unit is defined when we create the block here on the bottom left corner I think a lot of people don’t notice that even usually it’s not a problem but what’s important to know is the unit that appears here by default is what is set on the unit properties for the insertion content you might remember this when I explained in the tutorial for beginners when we insert content from a different file and that’s exactly what we are doing here let’s now have a look on the next example I’m going to change to this file where I have several door blocks I’m going to choose door one and this time you can see that the block unit is set to inches as in my current file the unit is millimeters the block has to be converted from inches to millimeters and the conversion factor is automatically calculated here it says 25 but is it correct do you remember if you look at the tables one inch is 25.4 millimeters but it shows only 25 why because on the unit properties I have this option set to not show decimals if I change it to two decimals or one decimal now you can see 25.4 it could be 25.40 but it doesn’t show the zeros at the right of the comma because it’s no need since sataka 2020 there is a new palette to insert a block from other drawings it can be quite useful I click on it then I need to click on this Ellipsis to find a different file and here you have the blocks within that file this is a nice feature it’s faster to search for blocks and also you have in this panel tabs that group the blocks from other drawings recent blocks that you used and the blocks from the current drawing it also indicates which blocks are dynamic now to insert a block it’s easy double click in the one that I want go to the drawing and it just asks to specify the insertion point you can see here that is the only option ticked the disadvantage regarding the design center is that I cannot see the unit that the block was created anyway I don’t think that’s a big issue as I can always check it out on its properties and if you notice that it’s not in the right size when you insert a block you can simply apply a scale to it so among the elements on the design center we can also add layers from other drawings it’s very simple if I want a layer from this file send through this positionis I just need to double click on the one that I want and it’s automatically added you can see the new layer Arcos Pista to import more than one layer I select them and this time I do not double click it doesn’t work this way instead I click with the right button and choose add layers here you have them and remember that in the layer properties the layers are displayed in alphabetical order four dimension Styles it works the same way simple so you can play around this with the other elements and you will notice that they work all similar tool palettes it’s this icon here this is another way to insert content from different drawings I think this is something really useful in AutoCAD basically it’s a kind of library that organizes items into these different tabs which are called palettes all these items here come by default in AutoCAD and they are located in Sample files if you are curious those sample files can be found on the AutoCAD folder go to samples and all the default DWG files are there are Dynamic blocks normal blocks hatches or other kind of objects let’s open one of these files for example home space planner and you can see that there are just blocks here and actually we can get advantage of these files because we can use those blocks in our projects without the need to search for blocks on the internet these are also More Sample files now let’s go back on each palette here you can find specific elements blocks for architectural annotation mechanical electrical civil and so on to insert an element or object just click on it and click again in the drawing it’s very simple the only thing is that you don’t have insertion options here it uses the ones by default you can also insert the hatch for example I click in this dark red and place it there like this but be aware this doesn’t create any layer if you look at the hatch tab on the ribbon it just uses this specific color for this object and it went to the layer walls as it’s the current layer ok now I’m going to show you how to organize this palette if you click here with the right button you can use the palette group that you desire for example there are the parametrics here if I clicking civil it shows this one and so on look that there are also tables or even visual styles then these palettes can be customized if you click with the right button and then go to customize palettes on the left side you can see all the palettes and on the right the palette groups each group contains how many palettes as we want some just have one palette and others like The annotation design have several palettes as you guess all these can be customized just click and hold in one palette for example modeling and drag it to a palette group I put it on annotation and design and at the top the order here indicates how the palettes are sorted on the tool palette’s main window okay but actually I don’t want this palette here so to remove a palette click with the right button and click on remove now I want to show you how to add new palettes for example with blocks from other drawings what we need to do is to use the design center to bring content to the tool palettes so I have the design center window here and I want to add the blocks from the files that are in this folder if I click in any file with the right button there is an option here to create a tool palette click then wait a few seconds until the palette is generated and as you see it goes directly to the top of your current group and also only the blocks were generated then I’m going to repeat the process for the other files doors home assembles kitchen and windows all are generated and placed above back on customize palettes window I’m going to add a new group named my blocks and then move the new palette to this newly Creative Group when ready I can also remove these palettes from the group annotation and design as they are not needed anymore select the palette and press delete finally switch to my blocks and here you have the palettes with this nice organization so you can see at least in my opinion this is a very practical way to use blocks in your projects and it’s also possible to choose a specific block from one of your lost files and put it and put it directly on the palette now I encourage you to create your own palettes and you will see how organized your projects become external references I open a new file and here I want to attach a reference to a file that it was previously given to me this one project architecture imagine that I am a structural engineer and I want to draw here the structural plan or I could be an electrical technician and I want to draw electrical circuits there so on my new file I go to the insert Tab and on the reference panel this is the panel that controls references click on this Arrow to open the external reference palette an alternative way is typing the command xref or external reference at the moment I just have here the current file you can recognize it by the DWG icon then if I switch to project architecture now you can see that the current file changes it also has an additional element which is an attached image the details of each file you can check out on this part below this is a JPG file that image is the one that I added to the title block on the layout tabs here then if I click on cutting black logo with the right button I can detach the image in a load and you can see it disappearing but I don’t want to do it so I click again with the right button and click on reload so to attach here the file project architecture I go to this icon then I click on attach DWG select the file in this window I click again on OK or specify the insertion options that I want at this moment I’m not going to scale the reference the option specified on screen is not ticked and I specify the insertion point if you remove the tick on this box the base point will be on the coordinate specified below and if it’s zero zero zero the base point will be on the origin click on OK and place now the base point where I want I’m going to put a coordinates in the origin so I type 0 press tab 0 again and press enter so here you can see the reference to the project architecture and it’s easy to recognize because it’s darker than usual at the file references list you can see the new attached file the DWG the project architecture and the image that was in that project is also shown here and it appears with the name of the file first and then the name of the image The Cutting black logo however sometimes for any reason some of the files attach it might not load because the program can’t find the file and even if you click on reload nothing happens so the solution for this is clicking on change path and search for the file on your computer how to edit an external reference in a drawing if I click on the image you realize that everything is selected I cannot select a line by line or or an object by the object also on the ribbon it shows up a new tab called external reference here I can create a clipping boundary on a part of the drawing and other options example let’s say in this project I only want to show the floor plan below I click on create clipping boundary then I select rectangular draw a rectangle around the drawing and do all the other parts of the file just disappeared I can also invert the part of the drawing that is showing by clicking on this grip now let’s use a different clipping boundary I’m going to click on polygonal and it could be useful if in a different case I would like to select this drawing below or the drawing above and not the one in the middle so the purpose of using external references is to allow two or more people working in the same project now let’s suppose I have a specific task in this project look to the layer properties now they are a bit different as I’m using external references on the filter section I can choose which type of layers that I want to display the layers on Gray are from the external references first you can see the file name and then the layer name for example at this moment I have all the layers shown on the screen now I switch to the all non xref layers or I can see only the layers from the external reference so it’s not hard to work with external references as you can see but I recommend you to practice a bit to interiorize all the steps that I have been showing to you part 5. we are going to discuss here multi-leaders and the properties panel multi-leaders are an interesting way to add annotations to our drawings they consist in an arrow that connects to a text or a block with an attribute let’s have a look to it a bit more in detail we can add a multi-leader from The annotation panel at the Home tab or if we switch to The annotation tab there is a full panel dedicated exclusively to leaders the first thing I should do is check out the settings by clicking in this Arrow here so it opens a window very identical to the dimension style manager let’s select the style the standard one and modify it here I’m going to start with the text height and because it’s too small I’m going to change it to 250 as my text labels are 350. this will be just a bit smaller then on leader format I want also to change the style of the arrowhead for example 200. only the structure I have by default 2 leader points then uncheck the box for landing distance if I don’t want it to be a fixed value I click on OK to confirm the changes and close the window so now I can add a letter it’s easy just click on the multi-leader icon choose the base point then specify the leader Landing location and click one time more to type the text for example external wall as it’s what the leader indicates then change here the layer style to annotative nice this time I’m going to repeat the process but instead I’m going to add an annotative multi-leader to appear in this viewport in the scale 1 per 100. change here the layer style to annotative and then on the multi-leader style manager click on modify so I will not change the settings because I think they are quite acceptable I close the window don’t forget to make sure the scale is correct 1 per 100 and draw the motivator for example window now if I double click on the Arrow I can see the quick properties of the multi-leader for example let’s change the landing distance to 10 and you can see the distance updating automatically so if I switch to the layout tab I can see how the annotative multi-line looks like multi-leaders have two types of content multi-line text or a block with an attribute which it’s this example here now I’m going to show you how to make this go again to the multi-leader style manager and here I’m going to create a new style I select this time annotative and click on new so my new style will have the same settings as the annotative style choose the name for it and when I’m ready I click on continue on this window we go to content and change the multi-leader style to block in this list as you can see there are already several blocks for multi-leader that come with AutoCAD apart from this I can also use a block made by me but this time let’s use this circle then I can change the scale but I’m going to keep it one have in mind that in this kind of multi-leaders using a block we don’t specify the height of the text then I create a multi-leader somewhere here and as the text inside the block is an attribute I’m asked to insert the value let’s put one for it and click on OK to confirm this choice okay I don’t like to match this position so let’s use the grips to put it a bit here inside now it’s good and you can see that it has an acceptable size on the layout let’s add another multi-leader and this time I put 5 for the value you can see how simple it is one disadvantage in multi-leaders unlike dimension lines if I change the multi-leader style settings the existing objects do not update automatically so if I decide I want to change the block I have to draw them again as you see I inserted the arrow with the new block on the next example I’m going to add a multi-leader using a standard style non-annotative so if I use the scale one it will be too small for the drawings that I have here I need to increase it let’s try with 20. then I close this window I’m going to draw the leader ah and you can see that the block I have here is a bit different this one has two attributes I just put random values and now the size fits quite well for this drawing have in mind that using the blocks by defaulty multi-leaders can be hard to measure exactly actually what happens is the measurements themselves are defined at the Block editor when I specify the multi-leader settings I can just set the scale each multi-leader can have more than one Arrow if I click on ADD reader then I select the multi-leader I can add an extra leader so this is as simple as it looks and it’s possible to add how many leaders as I want I could place another from this point or press escape to cancel the command to remove a leader just click on the icon located below select first the object and then click to remove the arrow now let’s talk a bit more in detail about the properties of objects you can find an entire panel here as you can see there are three main tabs the first is for the color the second the line weight and the third the line type by default these settings follow the properties of the layer where the object is now suppose I want to change the color of only a certain object I click on it go to the color Tab and change it to Red for example so at this moment the color of the object is not regulated by the layer color next situation now I have a block and you will see that they can activate different if I try to change the color you can see that it doesn’t work and as you remember we should put the lines that form a block in the layer 0 before creating it so I’m going to copy this block and then I use the command explode to return to its original objects if we want to give more freedom to the block before creating it we set the color of the objects as by block then I convert the door to a block I finish and as you can see it’s possible to change the color to follow the layer or choose the specific one like I did before there are also several ways that I can play with colors in blocks for example I can set the color of these two objects to an orange then I create a block and what happens is that when I change the layer those two objects will always keep the same color line weights I’m going to select this line and change the line weight here to one millimeter but nothing seems to change why the line weight at the status bar is Switched Off so I need to switch it on to see it if you don’t find this icon there go to the corner click in these three lines and find it on the list there also looked at the weights measure exactly how they are printed one millimeter and no matter the scale that we are using so basically the line weights are annotative now I’m going to switch off the icon show line weights and now even the line looks similar as the others also it’s not displayed on the layout it’s still there when you print the project or publish a PDF here you have it and now you can ask why does not AutoCAD show the line weights by default honestly I’m not sure about the answer but I think it’s to not have the workspace too messy with different weights of objects especially if there are lots of them basically it’s up to us to decide if we want the line weights or not like line weight there is a similar option to add a thickness in this case for polylines I can use the command P edit it means polyline edit I select the polyline I select a polyline and you can see several options to use here for example I can turn into a spline or click on the curve to come back to the original polyline along with other options that you can explore later if I click on the third option I can add the width then it prompts specify a new width for all segments this time this width value is the real size like when you draw standard dimensions or standard text so let’s type 50 and the polyline has this new shape I can still snap to the object snap points and they are now in the middle because when we add a width to a polyline it basically expands to the sides extra tip if I wanted I could draw a wall just using one polyline with a specific width for example let’s draw this rectangle with 5 meters per 2 meters then I right click and this is a different way to access the settings that you can find on P edit I select with and put the thickness of 150. so this could be a wall however look what happened here in the corner it looks like that these joints are not connected and this is because the polyline is not closed I open again the right click menu and this time on polyline I click on close to have the results that I want now let’s talk about the remaining setting the line type I’m going to select this line then I click in this tab to select the line type in this case there was already A Lash line selected but let’s see the others then click on load and you can find a bunch of line types in this list here let’s choose this one click on OK select it again here then it didn’t change I also have to select the line and now yes it chain it changes to the one that I want now let’s go to the properties there is a parameter very important here is the line type scale and we have to play with the numbers to know which range of values we need to put here another thing you can also notice that the current value is zero of course it’s not possible to have a scale of zero but the reason of this is on the unit properties I have the Precision set to no decimals I’m going to change it to two decimals and you can see that actually the current scale is 0.1 now let’s see how the line type scale works the smaller it gets the more difficult it is to see to distinguish the shape the larger it is is more likely to see just a continuous line or zooming into a gap let’s see another very important tip it’s common that we want the line types to appear in a specific viewport so as the viewports are in a specific scale this one is set as 1 per 100 we should set up the scale in the model space before choosing the line type if we do this the line type will look exactly as it is in the viewport on the other hand if my scale is set to 1 per 1 and choose the same line type this is the current appearance at the model space when I switch to a viewport that it scaled differently 1.100 in this case I can see that the appearance will not be the same so we reached the end of the tutorial too now I think you have enough knowledge to practice yourself remember that you can find a playlist with exercises in my channel page it’s really important to practice then when you are ready to learn more tips in AutoCAD you can watch the next tutorial which starts right now [Music] hi again so this tutorial is the continuation of the complete tutorial for intermediates that was playing right before let’s check out the contents first I’m going to focus on the status bar and then I will Explore More the topics dimension lines lines and polylines and other drawing commands and tips for texts let’s start [Music] in this first chapter I’m going to focus on some functions of the status bar that I haven’t explained before in the previous tutorials I will start with the isometric Drafting and to understand how it works we are going to draw this simple Cube which is represented as a 2d isometric projection there are three different planes that we can work on the left right and top and before starting let’s switch on the grid and you can notice when I turn on the other magic drafting for the left plane the cursor and the grid are automatically registered and the same happens with the snap mode and the also mode however the polar tracking doesn’t work for isometric Drafting and that means you should be in the Ursa mode to use this technique properly okay let’s make the cube I start with the left plane and this time I’m going to switch on both the grid and the snap modes even they are not required to help you visualizing the drawing process I’m going to start in a major intersection and then make the edges each of them measuring 200 millimeters so when I’m done with this face I change the plane to right and you can see how easily it’s now to draw the right side this time I switch off the snap mode because I don’t need it anymore and finally I turn on the top plane to draw the remaining gadgets now you can start practicing ISO drafting in your projects annotative scaling now in this drawing I have added annotative dimensions in different scales one per 50 1 per 10 and one per two so they appear in the viewport that has exactly the same scale as at this moment the annotative scale is one per one no dimension lines are shown here however if I activate this button all the dimension objects appear now in the workspace basically when this icon is off I can only see The annotation objects that match the current scale the next icon adds scales to annotative objects when The annotation scale changes has the following effect if I change the scale each Dimension line was added that scale and they will still appear if I change one of the viewports to the scale of 1 per 5. the gear hair that looks like a settings menu is actually meant for switching the workspace by default AutoCAD comes with three the current one is drafting and annotation which is used for drawing in 2D then we have two workspaces for 3D modeling first we have 3D Basics this one comes with simple commands in the panels for drawing 3D objects and as you can notice the buttons here are bigger than in the other panels finally we have 3D modeling and here the panels and menus are more complex plenty of commands to model our projects then if we are not happy with none of these workspaces we can create a new one in save current as and then customize it here in this option finally if we put the tick here we can display the workspace name in the status bar this button which represents a square circle and triangle is for isolating or hiding objects and it’s very simple to use let’s start with isolate then I picked these two objects press enter and as you can notice everything is hidden without this part on the other hand if I click on hide I can hide some objects from the screen and I’m doing it on these three ones as an example to return to the normal State I click on end object isolation and everything is shown again hide and isolate can be especially useful when in a complex project I want for example to make some changes in this specific section here I have decided to isolate this part and then hide the lines that I don’t need one last tip alternatively I can access these options from the right click menu and it’s exactly the same as what you can find on the status bar the next icon is the Autodesk trust DWG this function analyzes if the current DWG file was last saved with the Autodesk product or by a software developer license to use the real Autodesk toolkit if it matches this criteria you will have a green tick here if not you’ll get a warning instead of the tick and Autodesk cannot guarantee the application compatibility or Integrity of the file in other words if you were working in a dwj file in a different CAD software it may work properly here in AutoCAD but it’s not 100 guaranteed the next button is called clean screen and we just use it to switch to the full screen mode like this this can be useful if we want to work in a wider workspace so click on it again to get to the previous state finally we have customization here we can either remove icons to the status bar as we wish some of those used to be included in the status bar by default in previous versions and that was the case of the dynamic input I’m going to check this option and you can see it appearing just before the Ursa mode also have in mind that the tick doesn’t mean the function is turned on only that it’s displayed in the status bar so this function shows the input next to the cursor when I type anything with the keyboard such as a command name length Etc and look that it’s not showing it anymore when it’s off another function you can add to the status bar is the selection cycling and this one is very useful for complex projects let’s switch it on and basically when I click on two objects at the same time I mean when they are overlapped this window shows up so I can select the object that I want by default it selects the one in the front and in this case is the construction line but if I want the line that’s on the back I simply click here and it’s selected now this is important if you zoom out a lot and click in a place where is busy with objects for example here looked at the window shows up a big list that you can choose from in this case most of these objects are not necessarily overlapped but they are close enough so they still appear in the list okay in this chapter I will explain some extra tools for the dimension lines let’s start continue and Baseline on the next example suppose I want to add more dimension lines to measure the remaining distances along this side instead of creating Dimensions one by one there is a very useful tool that can save you considerable time if you are working on a huge project to continue dimension first I’m going to draw a vertical Dimension here then I’m going to push this button that says continue and suddenly it looks like I’m making another dimension in the same direction as the last one that I created here so as you can see it’s easy to Place several Dimensions by just clicking on the points that we want when you finish just press Escape I also want to explain you a tip as this command defaults to continue the last Dimension I need to click on select to change to a different dimension line for example I click in this one if I want to continue it to the right for example below the button continue we can find the Baseline with this feature we can make several dimension lines measuring a distance from the same point also look that the precedent is the same as for the continue command however there is a specification that’s a bit different the spacing between each line must be defined on the dimension style manager I’m going to modify the current style internal measures and on the line section we can change the Baseline spacing let’s increase it a little bit to 5. and then click on OK nothing has changed here in fact the new spacing only applies for the next Dimensions that I would draw I’m going to delete them and repeat Baseline again and look that the spacing is a bit wider than before another tip regarding baselines is about the position of the dimension It’s Curious that if the pointer is below the line in the text the new dimension will stay above it and if I move the cursor to the other side you can see that I’m switching the position of this new dimension line [Music] have a look at this example where you can see some dimension lines intersecting each other in order to avoid them appearing as normal lines we can add Dimension breaks at their intersections the icon is this one and the way this works is really simple I just need to click on the dimension line press enter and the break is added automatically at each intersection now let’s activate the command again another way to access it is by typing dim break and this time I select the dimension 600 and as you can see I broke it at these two dimension lines but stays continuous at this point because the break is already added in the previous dimension also brakes applied to any kind of objects that the dimension line intersects and to show you this I’m going to repeat the command in this drawing where this Dimension line intersects those circles look there is a break in all the intersections to edit the brake size I just need to go to the dimension style manager modify the style dims for exercises the current one go to the tab symbols and arrows and at the bottom you can see the section for the dimension break where I can change the brake size as an example I’m going to set 10 click on OK and now as you can see the Gap has increased [Music] Dimension space at the right of the icon theme break we can find Dim space when the dimensions are not well organized or we just want to set the same spacing between different levels we can use this command the process is the following first I need to choose the base Dimension which is the one that will not move then I pick the dimension to space let’s select this one with 200 millimeters of length press enter and then I can type a value or set an automatic spacing if I press enter again you can see the second dimension goes down and now the spacing between both matches the extension lines of the First Dimension okay now I’m going to undo this pressing Ctrl Z and repeat the command again I select the same base Dimension but this time I pick up these two I used again the auto spacing and now the three levels are separated equally let’s go back one last time I’m going to I’m going to do exactly the same but now instead of automatic let’s type a specific distance for reference I can look at that small dimension of 20 millimeters so let’s put the spacing a bit wider I think 30 is fine now this is how it looks like create a jog dimension [Music] this new example has a section at the right which is long enough to not fit in a paper and this representation means that this length is larger than what it looks like here so I’m going to add the dimension line but this time let’s use the tool continue then pick up this last dimension and place this new one here now the length of this Dimension line is 300 millimeters however the real size of that section is 1500. to represent that I need to add the Jack Dimension the button is located here and this is simple first I click on the button then select the dimension line and click exactly in the place where you want to add the chalk now to replace the current measurement I can simple double click on the text and change the value to 1500. basically what I’m doing here is adding a text of a right and it can be either as a text numbers or both finally select the dimension click with the right button go to Quick properties and there I can see the real measurement of the dimension which I cannot change it is 300 and the current text override now to display the real Dimension length again you can just erase the text to the right it’s also possible to edit the size of the jog in the dimension style manager I’m going to modify the current style in the simple scenarios tab there is a panel called linear jog Dimension here we have to specify a height factor with the text size as it’s currently set as 1.5 you can see the size of the jock a bit bigger than the text and if I change it to 3 click on OK and close the windows you can see now the chalk increased it to three times the size of the text okay now let’s have a look at extra tips to apply two dimension lines draw the dimension line at a specific distance from the object suppose we have this example and we need to add Dimensions to indicate the lengths of these lines in fact that’s easy to do we just need to activate the command Dimension linear click on two points and finally click again to place the damage line right okay now I’m going to do the same but for the left side and also let’s add a horizontal Dimension here in the bottom as you can see the dimensions are correct and there is nothing wrong with them but as you can notice I use the random distance from the lines for each of the dimensions okay maybe it’s not a big deal but in my opinion it’s better if we use a specific Dimension spacing for the entire drawing or even for the full project let’s see I’m going to do this again this time I’m drawing a dimension line measuring this section but then instead of clicking on a random location for placing the measurement I decided to have it for example at 500 millimeters above the line and when I see this extension track line I type 500 and press enter in this way I will have that distance between both objects then for the left Dimension I use the same method I hover the end point drag to the left and type 500 again finally I repeat the same process down here type the 500 millimeters and now you can see that all the dimensions have the same separation between the lines making the drawing looking nicer of course there are always exceptions in a rule let’s use the command continue for the dimensions above ah first I have to choose to select the object that I want to continue I click on select then on this extension line as you can see I am adding another dimension connected with the first one and finally add the third dimension by clicking in this last corner of course as you can see this last animation is far away from the line but in this way I can have all the dimensions in this side all along the same reference line finally here you have an example of this method applied in a floor plan set specific lengths for extension lines another nice setting is to set the fixed length for the extension lines those bars that limit the measurement using the default settings when I add more dimension lines all along this side and look that I can do it pretty quick by just clicking in each intersection they start from the points where I click with an offset Gap that is also specified in the dimension style manager I’m going to access that menu by clicking on the icon located on the dimensions panel select the dimension Style this one annotative and click on modify in this section below put the tick here to add the fixed length on all the extension lines as you can see the length here is three millimeters and actually as this is an annotative style this value means that the extension lines will measure three millimeters in a paper after printing it click on OK and you can see the result use template files with your own Dimension styles this is a good practice if we want to keep the dimensions with the same appearance in all the projects we are working on suppose you have a file about the project of the building X then your next one will be about the building Y and then the building set as you will probably use different DWG files for each project to keep the same Dimension Styles the best is to have a template and use it whenever you start a new project so in a new file which can be from a template you have created and I don’t have any objects here in the workspace I’m going to the dimensions tab on the annotative menu and click on manage Dimension styles so these are the default Styles I can modify any of them or create a new style if I want and that’s exactly what I’m going to do I click on new then on the first blank I should write the name for the new style start with means that I copy the settings of the style that is showing here in this case annotative below I decide if I want to use annotative Dimensions by checking this box and finally I can continue so now we can make the changes that we need text arrows primary units Etc I’m going to add just a suffix here as the symbol of millimeters because I put it on the title and click on OK to save the changes after I can add more styles for example let’s say I am creating a similar Style with the same settings except for the suffix I’m going to set meters and for that I put a scale factor to convert millimeters to meters of course this is in case I’m making the drawing in millimeters and when you are ready with your Styles let’s save this file as a template choose the name and save it on the default templates folder or create a new one in this way you can start your projects with the same template and you don’t need to edit the dimension styles again [Music] on the next chapter of this video we will go back to lines and polylines but this time we are going to learn some interesting tips that will help you to master these two commands let’s start with settings to edit in a polyline [Music] there are several features we can edit in a polyline and we are going to start with gloves to explain you this situation I’m going to use this example where we are going to draw this simple figure with the command polyline you will see that what matters here is the way we will draw the last line let’s activate the command polyline as you may know I can click on the icon at the ribbon or a faster way is using its Alias just type PL and press enter then I’m going to draw this irregular polygon and let’s make it beautifully starting at the same horizontal play first make sure object snap and Ortho mode are on hmm the Snaps are off let’s turn them on I’m going to hover this endpoint drag to the right following this truck line and then I type 200 millimeters to start the polyline at that distance from the corner then I draw each line by typing the exact length with the keyboard and to make the things easier for you you can just look at the left drawing as all the dimension lines are there also notice as we are inertia mode for the lines snap vertically or horizontally and in this way we can draw all the lines much faster I’m going to speed up the process and when I arrive at the last line I’m going to finish the polyline normally by clicking at the end point what happened is if I’m using the grips to modify the figure by trying to move the line at the bottom a bit down where we should click on this grip at the middle you can see it separates from the last line in contrast what happens if I try to do the same in these other segments look however let’s go back when we want to join the last line with the start point we can click on close or typing CL and this time I basically remove any start and last point from the polyline and the lines no longer break at the origin now I’m going to select the polyline and right click with the mouse let’s go towards polyline and there are several settings that we can do here if I click on open look what has happened the last segment that I inserted just disappeared leaving the polyline open instead if I click on close I get back to a closed polyline exactly how it was before with the options at the bottom I basically comfortably line into a spline if I choose cure fit you get this result and it’s exactly like drawing this figure using the spline fit command on the other hand if I convertibly line to spline fit it uses the method of drawing the spline CV command I know it sounds a bit counter-intuitive but CV actually means control vertices in the same menu related with the polylines we can add a width in case we want to represent that polyline a bit thicker comparing with the other objects in this drawing then we are prompt to insert a value because I have these Dimensions here as a reference I can guess more or less how the new thickness will look like let’s insert 10 and it should be more or less this distance type 10 press enter and here you have the result one characteristic when you add a width to a polyline is when you select it the grips are located at an imaginary line in the middle to get back to the previous day I go again to width but this time I’m going to type 0 to disable this property convert lines in a single polyline sometimes we are just drawing something and only after finishing we realize that we have been using the command line instead of polyline that’s fine and there is no needs to draw everything again of course there is a command for that the command join you can find it here on the modify panel that’s simple select all the objects and they convert to a single polyline [Music] line line types a lot of AutoCAD users have encountered problems when dealing with line types in addition the way they appear in the workspace can be very different than the viewports on the layout tabs all that strolling is due to the line type scale so in this tutorial we are going to explore this step by step hoping this won’t be a big issue for you back on the same drawing we are going to create a new layer here let’s name it dashlines and set the different color for example this light blue one next I select the drawing at the right and change it to the new layer on the layer properties manager there is a column about line types let’s change the line type for this layer and first I have to load a new one and as you can see there are lots of them that AutoCAD provides by default I select this ISO Dash space then don’t forget to select it also here click on OK and close as you can see the lines in that blue layer are now dashed now there isn’t any control to set the measure of each Dash or to set the quantity of dashes within a line that would be very hard to measure but what we can do instead is set the line type scale now in AutoCAD we can set a line type scale for a specific object or we can apply it generally for all the file and in that case all the lines that are not continue change their appearance so to set the general line type scale I type LT scale and press enter the default value as you can see is 1 and this drawing has the dashes with this size if I change the scale to 0.5 you can see the dash sizes are now half smaller if I am not happy with the result I can keep changing until I find the size that works for me so at this moment it doesn’t look hard but suppose now I draw a line very very large in comparison with the existing objects what happens here is with the same line type scale I cannot see anything as I don’t want to modify the other dashed lines I can do a different process select the line and go to properties and here you can see a setting for the line type scale by changing this value and this time I’m going to try a very huge one for example 50 and let’s see ah finally I can see the dashes properly without changing the lines that I have in the exercise that I showed you before now let’s go back but they seem to change um okay this is actually just a problem of loading the screen usually if you zoom the screen few times we’ve solve this problem but but in this kind of situations the best is to use the command region regenerate and now the dashes are visible again object snap overrides midpoint between two points imagine we are drawing a polyline or a line here the next point will be on the midpoint of this distance normally we would make a temporary line there and use its midpoint that’s a way however there is an alternative if I right click go to object snap overrides select mid between two points then you will see if I click on two points the line ends at the middle between them use a specific object snap mode sometimes you have probably noticed it’s hard to find the mode we actually want especially if a lot of them are turned on for that then go to oh snap overrides and choose the one we want to use right now for example if I select perpendicular it’s very easy to find a perpendicular intersection to this line okay let’s go on now I am going to show you extra drawing commands that you can find in this little section let’s start with spline it’s a command to create a smooth curve and there are two types the first one is blind fit here which is the point where the curve must pass through and when you finish press enter to confirm the spline if you press Escape instead you cancel the command and nothing is created so have this in mind then it’s possible to adjust the position of the curve by moving the grips the second method to create the spline is with controlling vertices now unlike the spline fit the curve doesn’t pass through the points that we specify as they are just vertices to control its position then this grip that looks like an eject button switches from fit to control vertices so you can use this if later you change your mind another command available here is the construction line it’s this button this creates an infinite line and it’s used mostly for drafting purposes one of the situations that can be useful is to draw an elevation of a floor plan like the example I’m showing to you right now the next command at the right is called Ray and it works in the same way as the construction lines as well we can use them as a reference to draw other objects the difference array is a semi-detached line it has an origin and continuous infinitely in the direction that we specify also the bullet tracking might be useful here if we need to create trays separated equally with a specific angle for example 15 select that option and then click where the pointer snaps other type of reference is simply a point I can click in this command multiple points and you can place them in strategic positions then in this example I’m going to add two points in two intersections of the track lines at the right we have two buttons called divide and measure they are very similar with divide we can create a certain number of space points along a line or another kind of object now I enter the number of segments for example 5 and press enter the only thing here is that we can’t just see these points if we delete the line or move it to another place so in conclusion I think this command can be useful if we need to place equally spaced points along a certain direction so in this case I can draw a line then use divide and erase the line at the end with the command measure instead of specifying the number of points I set the length between each of them as an example let’s type 20 and I divided the line in five sections [Music] in the last chapter we will talk about texts and this time we will focus on some a bit more advanced tips let’s check them out insert text height is not showing on the command bar not sure if this happened to you but sometimes when we are creating a text object let’s say a single line text for example we realize that it prompts directly to set a rotation angle of the text without asking for the text height previously this happens when our current text style has a specific height defined in its properties so in this situation we are on the style floor plan labels and the text style you can see here it’s defined as 500 so let’s cancel this first I’m going to access the text style properties and you can see the height here for floor plan labels is defined as 500. on the other hand the standard style let’s click on it remember that it prompts to specify a text height on screen due to the fact that the value here is set to zero so memorize this now let’s go back to floor plan labels and I’m going to change the height to zero apply the changes in close finally on the workspace after activating the command single line text the first prompt is to specify the height even the default one is 500 I can press enter to use this one or change to a different one if I want how to convert multi-line text to single line text and vice versa okay I’m going to insert a multi-line text object for the text style I’m going to use standard and if you look at the label there you can see it’s the current Style type the Alias t press enter and then click a new wire to start defining the window that I want to fit the text in and now as this style doesn’t have a specific height already defined I can change it here if I want so let’s set 150 for example okay now let’s Place three lines of text and as my point is just to explain to you how this works I’m going to put text 1 text 2 and text 3. finally click anywhere to confirm the multi-line text now imagine that later I decided to separate each line so this is very easy you just need to explode it and from now on we have three single line text objects here now the other way around in this file I have this floor plan and in each room I added a label as two single line texts with different heights each one is for the name of the room and the text below indicates the area in square meters so it’s also possible to merge both on the M text and there is a command for that its name is a bit complex by the way txt 2 m t x t yes it’s strange but actually it’s not hard to memorize as it means text to M text but don’t worry because once you type the first two letters it shows up on the command list then you press enter and notice that the texts became a bit closer and the reason is to follow the spacing that is defined in a multi-line text between its lines OK this is a multi-line text now and if you double click on it you can access the text editor as usual for changing the settings if needed another thing this tool still works even if the objects are displayed randomly around the screen the only problem is when applying text to M text they may not organize how we expect so you have to do it manually simple in closed text in object now look at the labels that we had on the floor plan but to simplify the things I copied them to an empty space here because I think it’s easier to understand properly how this tool works ah and to be even better let’s move also the areas which are in a smaller size a bit below now let’s switch to the express tools menu and specifically at the text panel these are basically some Advanced operations regarding texts and their look there is also this command the txt2mtxt that I was focusing earlier in this video but okay what we need now is this button enclosed to object I’m going to click on it then I select all the objects press enter and then the first prompt is to insert an offset factor and be aware that this is not a distance it’s just a factor that still has inconsideration the size of the text as a first attempt I’m happy with these one value so I press enter and for the type of object let’s go for rectangle then we have here two options constant and variable and to understand better the difference there is nothing like seeing the result I click on variable and now the object size differs according to the length and size of each text so that’s why the rectangle in bedroom 1 is wider than in path if I choose constant instead then there is another box asking me what I want to maintain constant if the width the height or both so this time I’m going to choose both and now all the rectangles are exactly the same even the ones around the areas whose text height is smaller basically the system takes the largest rectangle and places it around the remaining objects now let’s look what happens when we change the offset Factor if I set it to 5 the objects become bigger the only problem that it’s maybe hard to guess the size that the object will have unless you have a lot of practice but you can try a few times until you find the value that you are looking for finally there are two more types of objects that we can use circles and slots and the available settings are exactly the same as for the rectangles one last thing the text and object keep their independence in a way that in this situation the circle is not following the text if I change the text size this was something when I was exploring this command I didn’t understand what variable and constant meant I thought when we change the text height or the text itself the object would adapt to the new size but it didn’t actually variable and constant only works for a multiple text selection [Music] mirror text in AutoCAD by default text objects are not mirrored when we use that command to make a symmetry copy of a specific drawing as you will see in this situation the texts are copied but without inverting the letters just because I think most of the time we don’t want that to happen however if in a hypothetical situation we need to display the text backwards we only need to change the system variable mirror text enter and here we have two options if I set 0 which is the mode by default the text is not mirrored so to enable this ability I set 1 press enter and now if I apply the command mirror to these objects at the right look that now the texts are backwards insert the field in a text this is a very interesting and useful Advanced option available in AutoCAD a field is basically a way to insert data that we expect to change during the cycle of a drawing ah this is actually the definition that you can see on the Autodesk website by the way as an example I provided to you this file where I have attached an image from a satellite view of a part of a town right in the center of Africa now suppose the image is already scaled to have its real proportions in meters the unit I specified for this project now I’m going to add a polyline to measure a specific area let’s make it around these houses and the accuracy here is not very important I just want to show you how this works then let’s add a text object and I will type for it area of the terrain with the current value displayed here and the main point is that the area updates automatically if I decide to change the size of that polyline so I right click with the mouse and go to insert field in this window from the category list we can add date and time that could be useful for a layout sheet among other options let’s pick up objects and then press this button to select a specific object which in this case is this body line I click on it and then at the right section there are several parameters that we can display let’s choose area and that the section at the right first we can see a preview of the result above and this means it’s going to be 3248 square meters then here we can choose the format at this moment decimal is fine for me below it’s the Precision and in additional format we have extra options like conversion factor in case we need to display the result in a different unit than the one I set for the project and an additional text for example I can add an indication of square meters as a suffix click on OK and close the window now the error is displayed within the text also notice that the values are showing highlighted but don’t worry in case you want to print as on the paper this rectangle around the number will not appear finally as I mentioned before the great thing of using Fields is that I can change the area of the polyline and the value updates automatically okay sometimes we have to save the drawing and open it again to notice the change but you can always use the command Regen to update the value in this precise moment so it was everything for today but this time before leaving I want to mention that I just started the page of patreon for gazing plan there you can support this channel to help me keep creating more content here I would really appreciate that even of course I’m already grateful that you find these videos available and that they are helping you to speed up your knowledge without your support nothing of this would be possible so thank you very much for watching see you next time
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
The source is a Python programming tutorial. It explains fundamental concepts, data types, and structures like strings, integers, booleans, lists, sets, and dictionaries. It also covers functions, modules, object-oriented programming (OOP) principles using classes, and file handling, specifically with spreadsheet data. The tutorial provides practical coding examples and discusses built-in modules for tasks like date/time management. It further explores how to install external packages for more specialized operations and encourages logical thinking alongside coding skills. The tutorial is geared towards beginners, particularly those interested in devops engineering.
Python Fundamentals Study Guide
Quiz
Instructions: Answer the following questions in 2-3 sentences each.
What is an Integrated Development Environment (IDE), and what are some of the benefits of using one?
Explain the difference between integers and strings in Python. Provide examples of each.
What is string concatenation, and how is it achieved in Python? Show an example of string concatenation.
Why are variables useful in programming? Describe the advantages of using variables in your code.
In Python, what is a reserved word? Provide two examples and explain why they can’t be used as variable names.
What are functions? Describe the advantages of using functions in your code.
Differentiate between global and local variables. Why is understanding variable scope important?
What is a conditional statement? Explain how ‘if,’ ‘elif,’ and ‘else’ statements are used.
How can you handle potential errors or exceptions when asking for user input in Python? Describe what a ‘try/except’ block does.
Explain the difference between a list and a set in Python. When would you choose to use one over the other?
Answer Key
An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. Benefits include syntax highlighting, code completion, and integrated debugging tools, all in one place to streamline development and make a developer’s job easier.
Integers are whole numbers (positive, negative, or zero), while strings are sequences of characters (text). For example, 10 is an integer, and “Hello” is a string.
String concatenation is the process of combining two or more strings into a single string. In Python, it can be done using the plus sign (+) or f-strings. For instance, “Hello” + ” ” + “World” results in “Hello World”.
Variables are useful because they allow you to store and reuse values throughout your code, avoiding repetition and making your code more readable and maintainable. By using variables, you only need to change the value in one place, and it will be reflected everywhere the variable is used.
Reserved words are words that have special meanings to Python and cannot be used as variable names. Examples include def and if. Using them as variable names would cause syntax errors, as they would conflict with Python’s built-in language constructs.
Functions are blocks of organized, reusable code that perform a specific task. Functions promote code reusability and make your code modular and easier to understand by breaking down complex tasks into smaller, manageable units.
Global variables are defined outside of any function and can be accessed from anywhere in the code, while local variables are defined within a function and can only be accessed within that function. Understanding scope is important because it determines where a variable can be used and helps prevent naming conflicts.
A conditional statement allows you to execute different blocks of code based on whether a certain condition is true or false. The if statement executes a block of code if a condition is true, elif (else if) checks an additional condition if the first condition is false, and else executes a block of code if none of the preceding conditions are true.
To handle potential errors when asking for user input, you can use a try/except block. The code that might raise an error (e.g., converting user input to an integer) is placed inside the try block, and if an error occurs, the code inside the except block is executed, allowing you to handle the error gracefully.
A list is an ordered collection of items that can contain duplicates, while a set is an unordered collection of unique items (no duplicates). You would use a set when you need to ensure that all elements are unique and when the order of elements doesn’t matter, and a list when you need to maintain the order of elements and allow duplicates.
Essay Questions
Instructions: Answer the following questions in essay format, drawing upon the source material.
Discuss the importance of code style and readability. How can tools like PyCharm aid in maintaining consistent code style?
Explain the concept of “decomposition” in programming. How do functions contribute to code decomposition, and why is it important for managing complex projects?
Describe the process of validating user input. Why is input validation crucial, and what techniques can be employed to ensure data integrity?
Explain the benefits of using modules to organize your code. How do modules promote code reusability and maintainability in larger projects?
Discuss the different data types available in Python, such as strings, integers, floats, lists, sets, and dictionaries. Explain why it’s important to understand and utilize appropriate data types to accomplish specific tasks.
Glossary of Key Terms
IDE (Integrated Development Environment): A software application that provides comprehensive facilities to computer programmers for software development.
Data Type: A classification identifying one of various types of values that determine the possible values for that type, the operations that can be performed on that type, and the way values of that type can be stored.
String: A sequence of characters; a data type used to represent text.
Integer: A whole number (positive, negative, or zero); a data type used to represent numeric values without fractional parts.
Float: A number with a decimal point; a data type used to represent numbers with fractional parts.
Boolean: A data type with only two possible values: true or false.
String Concatenation: The process of combining two or more strings into a single string.
Variable: A storage location paired with an associated symbolic name (an identifier), which contains a known or unknown quantity of information referred to as a value.
Reserved Word: A word that has special meaning to a programming language and cannot be used as a variable name.
Function: A block of organized, reusable code that performs a specific task.
Global Variable: A variable defined outside of any function, accessible from anywhere in the code.
Local Variable: A variable defined within a function, accessible only within that function.
Variable Scope: The region of a program where a variable can be accessed.
Conditional Statement: A statement that executes different blocks of code based on whether a certain condition is true or false (if, elif, else).
Comparison Operator: Symbols used to compare two values (e.g., >, <, ==).
Boolean Value: A value that is either true or false.
Exception Handling: The process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution.
Try/Except Block: A construct used to handle exceptions.
Loop: A sequence of instructions that is continually repeated until a certain condition is reached.
List: An ordered collection of items that can contain duplicates.
Set: An unordered collection of unique items (no duplicates).
Dictionary: A collection of key-value pairs, where each key is unique.
Module: A file containing Python definitions and statements; a way to organize code into reusable units.
Built-in Function: Functions that are available in Python without needing to import a module (e.g., print(), input(), int()).
Package: A way of organizing related modules into a directory hierarchy.
pip: A package management system used to install and manage software packages written in Python.
Library: Describes package that includes multiple other packages, a hierarchy of packages.
Python Programming: Core Concepts and Usage
Okay, here’s a detailed briefing document summarizing the main themes and important ideas from the provided text.
Briefing Document: Python Programming Concepts
Overview:
This document summarizes key concepts in Python programming, as taught in a course or tutorial. It covers fundamental topics like Integrated Development Environments (IDEs), data types (strings, integers, floats, booleans), string concatenation and formatting, variables, functions, user input, conditional statements (if/else), loops (while, for), lists, sets, dictionaries, built-in functions, modules (including datetime and OS), package management (pip), and file handling with external packages (openpyxl).
I. Setting up the Development Environment:
Integrated Development Environments (IDEs): IDEs like PyCharm provide a comprehensive environment for writing and executing code. They offer features like:
File navigation within the project.
Built-in execution environment (eliminating the need to use a separate terminal).
Syntax highlighting.
Error highlighting.
Code suggestions and autocompletion.
“Integrated because you have everything in one place so you don’t need to use terminal but in addition to this integration you get more cool features which helps you in writing python code for example syntax highlighting highlighting errors or code suggestions autocomplete suggestions and we will see those cool features actually also throughout this course so basically just makes your life as a developer easier…”
II. Data Types:
Strings: Textual data is represented as strings, enclosed in either double quotes or single quotes. There’s no functional difference between using single or double quotes.
“everything within the double quotes is basically a string but note that in python you can also use single quotes for strings so double quotes or single quotes they both work the same and there’s actually no difference between them”
Integers: Whole numbers (positive, negative, or zero) are represented as integers.
“for whole numbers like 2 20 but also 0 and negative numbers as well we have a data type called integer and that’s also how it’s called in most programming languages”
Floats: Numbers with decimal precision (e.g., currency values, weights) are represented as floats.
“however you also have numbers for currency for example how much a product costs right so if you have an online shop you would have prices like this for example so these are basically numbers with precision”
Booleans: Represent truth values: True or False. Used extensively in conditional statements.
“and those true and false values in programming actually are represented by its own data type which is called boolean”
III. String Concatenation and Formatting:
String Concatenation: Combining strings using the + operator. Requires explicit conversion of non-string data types to strings using str().
“we combine the strings using plus sign so apart from adding numbers obviously using plus plus is also used in programming for combining multiple strings”
“if we just put a number here python interpreter tells us it’s not a string it’s a number so we need to turn it into a string”
Formatted String Literals (f-strings): A more elegant way to embed expressions within strings, using curly braces {} and the f prefix before the string. Requires Python 3.6 or later.
“instead of having these plus we have curly braces and we write our number inside or whatever non-textual value and at the beginning right here basically before we start writing a string which starts with quotes we just write the letter f”
“this f actually stands for format so this is basically formatting our text or our string in a correct way”
IV. Variables:
Variables store values that can be reused throughout the code. Python’s variable definition is simple: variable_name = value. No explicit data type declaration is needed (unlike some other languages).
“in python defining or creating a variable and giving it a value like this syntax for that is actually very simple compared to other languages because you just have the variable name and the value in many programming languages you actually have to define here some kind of data type for that variable for example if it’s a number like float or integer or string etc in python you don’t have to define that”
Naming Conventions: Use descriptive variable names, separating words with underscores (e.g., calculation_to_seconds). Avoid using reserved words (keywords) as variable names.
“variables that are descriptive so basically they tell you what this value actually is about so they have multiple words in them you can separate them using these underlines”
V. Functions:
Functions are reusable blocks of code that perform specific tasks. They are defined using the def keyword.
“functions are basically blocks of code like this right or basically logic in code that does something it’s not just simply a value but actually does something more complex that is again used in order to avoid repeating the same logic or most of the same logic in your code”
“we start with def so we define a function just like we define a variable but for function we need this keyword basically called def”
Parameters: Functions can accept input values called parameters, defined within the parentheses () in the function definition.
“instead of having this 20 basically here hard coded as we said here and here we provide that value of 20 or 35 or whatever that value is basically whenever we use the function”
Calling Functions: Functions are executed (or “called”) using their name followed by parentheses, optionally including arguments for the parameters: function_name(argument1, argument2).
“whenever you create a function or define a function like this you actually have to use that function right”
“How do we use a function or in programming languages it’s called calling a function or executing a function and we do that using the name of the function like this”
Variable Scope:Global Scope: Variables defined outside a function are accessible to all functions in the code.
Local Scope: Variables defined within a function are only accessible within that function.
“variable has a global scope for a function if it is defined outside the function like these two variables right here could be completely in a different file not even in the same file where the function is so these are global variables”
“local variables are variables that are created within that function right so these two variables are basically only available inside that function because it was created within that function so internal scope and global scope”
VI. User Input:
The input() function prompts the user to enter a value. The input is always returned as a string.
“accepting a user input from a python application is actually pretty easy let’s get rid of all of these lines first and we can do that by writing input and this will basically give a user a prompt to enter some input value”
VII. Conditional Statements (if/else):
if statements execute a block of code if a condition is true. else statements provide an alternative block of code to execute if the if condition is false. elif (else if) allows for multiple conditions to be checked in sequence.
“if condition then do something otherwise do something else and that conditional can be true or false”
“in the if else statement in programming we can have multiple conditionals so basically we can have multiple ifs so how do we do that first we check number of days is greater than zero okay great now we want to check whether number of days is equal to zero and we can do that using another if here and in python the syntax for that is el if which basically is a combination of else and if”
Comparison Operators: Used to compare values in conditional statements (e.g., >, <, == (equals), >=, <=, != (not equals)). == checks for equality; a single = is used for assignment.
“this greater than sign is called a comparison operator and we have three of them we have greater than less than and equals and these are called comparison operators because they are used in an operation to compare two values”
Boolean Data Type in Conditionals: The condition in an if statement evaluates to a boolean value (True or False).
“this conditional will either give true or false what i’m going to do is i’m going to print this conditional right before i do the check so for a positive number input this should print true and if it’s negative so it’s not greater than 0 this should print false”
VIII. Loops:
while Loops: Execute a block of code repeatedly as long as a condition is true.
“the second type of loop is called while loop and that while loop will basically keep that block of code that is part of it executed again and again as many times as needed and in order to say how many times the code needs to get repeated we again need a condition”
for Loops: Iterate over a sequence (e.g., a list, a string) and execute a block of code for each item in the sequence.
“we have another type of loop called for loop and basically we want to execute validate and execute function using a for loop”
IX. Exception Handling (try/except):
The try block encloses code that might raise an exception (error). The except block handles the exception if it occurs, preventing the program from crashing.
“we put potentially dangerous code in that try and if anything bad happens within this logic within this logic block that we put in the try block if there is any error happening python will automatically catch this error and will transfer the execution flow automatically right here to the code that we specify after the accept”
X. Data Structures:
Lists: Ordered, mutable (changeable) collections of items, enclosed in square brackets []. Lists can contain items of different data types. Lists allow duplicate values.
“the syntax for list is using square brackets and inside the square brackets we have a list of elements and those elements can again be either strings numbers or boolean values”
Sets: Unordered collections of unique items, enclosed in curly braces {}. Sets do not allow duplicate values.
“set is basically a list of elements but with unique values inside so list data type allows duplicate values the same value multiple times set does not allow duplicate values”
Dictionaries: Unordered collections of key-value pairs, enclosed in curly braces {}. Keys must be unique and immutable (e.g., strings, numbers).
“dictionary is basically a collection of key value pairs”
“each element in this dictionary has key and a value”
XI. Built-in Functions:
Python provides a variety of built-in functions that perform common tasks (e.g., print(), input(), int(), str(), len(), set(), type()).
“functions that we ourselves didn’t actually write and the functions that python basically makes available for us to use are called built-in functions”
Some built-in functions are called directly (e.g. print(x)). Other built-in functions are called on a specific object (e.g., my_string.split(), my_list.append()).
XII. Modules:
Modules are files containing Python code that define functions, classes, and variables. They provide a way to organize and reuse code.
“modules are basically just organizing your code into multiple python files like that and then accessing some parts from a module like functions variables etc from one file from another and the goal here is basically not to put the whole logic into one single massive file but rather to have it nicely separated based on the logic”
Importing Modules: Modules are imported using the import statement. Specific elements (functions, variables) can be imported using from module import element. All elements can be imported using from module import *. Modules can be renamed using import module as alias.
“you can pick and choose which specific functions you want to make available inside another file or another module and you can do that very easily using the following syntax we say from helper that’s the module again import and the name of the function like this”
Built-in Modules: Python includes several built-in modules that provide functionality for various tasks (e.g., os, datetime, logging).
“we can actually use modules that python itself already includes so just like we used some functions that python gives us out of the box like inputs or ins so basically all of those the same way python also gives us modules for different scenarios so that we don’t have to write this logic ourselves”
XIII. Package Management (pip):
pip is the package installer for Python. It is used to install and manage external packages and libraries from the Python Package Index (PyPI).
“in python we install packages using a package manager tool called peep”
“pip is a package manager for python”
pip install package_name installs a package.
External packages extend Python’s functionality and provide ready-made solutions for common programming tasks.
XIV. File Handling with External Packages (openpyxl):
External packages, such as openpyxl, provide specialized tools for working with specific file formats (e.g., spreadsheets).
“there is an external package that allows you to work with spreadsheets specifically”
Packages like openpyxl offer functions for reading, writing, and manipulating data in spreadsheet files.
This document provides a high-level overview of the Python concepts covered in the source text. It emphasizes definitions, syntax, and key use cases for each topic.
Python Development Fundamentals
IDEs, Data Types, and String Concatenation
What is an IDE and why is it useful for Python development?
An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. IDEs like PyCharm bundle common developer tools into a single graphical user interface (GUI). This usually consists of a source code editor, build automation tools, and a debugger. In the context of Python, an IDE integrates file navigation, code execution (eliminating the need for a separate terminal), syntax highlighting, error highlighting, code completion, and other features that simplify and accelerate the coding process, making developers more productive.
What are data types in Python, and can you provide examples of common data types?
Data types are classifications that specify which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. Common data types in Python include:
Strings: Used for text. Strings are enclosed in either single quotes (‘) or double quotes (“) e.g., “Hello” or ‘World’.
Integers: Used for whole numbers (positive, negative, and zero) e.g., 2, -20, 0.
Floats: Used for numbers with decimal points, representing numbers with precision e.g., 2.99, 150.00.
Booleans: Represents true or false values.
What is string concatenation and how is it achieved in Python?
String concatenation is the process of combining multiple strings into a single string. In Python, string concatenation can be achieved using the + operator or f-strings (formatted string literals). The + operator joins strings together, while f-strings allow you to embed expressions inside string literals, which are evaluated at runtime and formatted accordingly. F-strings are generally considered more readable and efficient.
What are f-strings in Python, and what advantages do they offer over traditional string concatenation methods?
F-strings, introduced in Python 3.6, are a more concise and readable way to format strings. An f-string is a string literal prefixed with f or F. F-strings offer several advantages:
Readability: They allow you to embed expressions directly within string literals, making the code easier to read and understand.
Conciseness: They eliminate the need for explicit string concatenation operators or formatting methods.
Efficiency: F-strings are generally faster than other string formatting methods because they are evaluated at runtime.
Direct Embedding: Instead of needing to convert a data type to a string and then concatenate, f-strings allow for direct embedding using curly braces.
Variables, Functions, and Program Control
What are variables, and why are they used in programming?
Variables are named storage locations that hold values in a computer’s memory. Variables are used in programming to store data that can be accessed, modified, and reused throughout a program. Variables help to avoid repetition of values, enhance code readability, and make it easier to update values in multiple places by changing the value of the variable once.
What are functions, and how do they help in writing modular and reusable code?
Functions are self-contained blocks of code that perform a specific task. Functions help in writing modular and reusable code by encapsulating logic into named units that can be called from different parts of a program. Functions promote code organization, reduce redundancy, and make it easier to maintain and update code. Functions can accept inputs (parameters) and return outputs.
What are variable scopes (local vs. global), and how do they affect the accessibility of variables within a program?
Variable scope refers to the region of a program where a variable can be accessed. There are two main types of variable scopes:
Local scope: Variables defined within a function have local scope, meaning they can only be accessed within that function.
Global scope: Variables defined outside of any function have global scope, meaning they can be accessed from anywhere in the program, including inside functions. It is possible to have a local and global variable with the same name, where the local variable “shadows” the global variable.
How can conditional statements (if/else) and loops (for/while) control the flow of execution in a Python program?
Conditional statements (if/else) allow you to execute different blocks of code based on whether a condition is true or false. Loops (for/while) allow you to repeat a block of code multiple times, either a fixed number of times (for loop) or until a condition is met (while loop). These control structures enable you to create programs that can make decisions and perform repetitive tasks efficiently. If-else statements can be chained using elif to check multiple conditions in sequence.
User Input, Error Handling, and Data Structures
How can you prompt the user for input in Python, and why is it important to validate user input?
You can prompt the user for input in Python using the input() function, which displays a message to the user and returns the text entered by the user as a string. It is important to validate user input to ensure that it is in the expected format and range, preventing errors and crashes in your program. Validation can involve checking data types, verifying numeric ranges, and sanitizing input to prevent security vulnerabilities.
What is exception handling (try/except), and how does it help in writing robust and error-resistant code?
Exception handling (try/except) is a mechanism for handling errors that occur during program execution. The try block encloses code that might raise an exception, and the except block specifies how to handle that exception if it occurs. Exception handling allows you to gracefully recover from errors, prevent program crashes, and provide informative error messages to the user. Using exception handling allows a program to continue running even when an error occurs.
What are lists, sets, and dictionaries in Python, and what are their key differences and use cases?
Lists: Ordered collections of items that can be of any data type. Lists are mutable, meaning their elements can be changed after creation. Lists allow duplicate values.
Sets: Unordered collections of unique items. Sets are mutable and do not allow duplicate values. Sets are useful for removing duplicates from a collection and for performing set operations like union, intersection, and difference.
Dictionaries: Collections of key-value pairs, where each key is associated with a value. Dictionaries are mutable and allow you to access values efficiently using their corresponding keys. Dictionaries are useful for storing and retrieving data based on unique identifiers.
How can you iterate over a list or set using a for loop, and how can you access values in a dictionary using keys?
You can iterate over a list or set using a for loop by specifying the list or set as the iterable object. The loop variable will take on the value of each element in the list or set, one at a time. You can access values in a dictionary using keys by specifying the key inside square brackets ([]) or by using the get() method.
my_list = [1, 2, 3]
for item in my_list:
print(item) # Prints each element: 1, 2, 3
my_dict = {“a”: 1, “b”: 2}
print(my_dict[“a”]) # Prints 1
print(my_dict.get(“b”)) # Prints 2
Modules, Packages, and File Handling
What are modules and packages in Python, and how do they help in organizing and reusing code?
Modules are individual Python files that contain functions, classes, and variables. Packages are collections of modules organized into directories. Modules and packages help in organizing and reusing code by breaking down large programs into smaller, manageable units. Modules can be imported into other Python files, allowing you to access their contents. Packages provide a hierarchical structure for organizing modules, making it easier to manage large codebases.
How can you import modules and packages into your Python code using the import statement?
You can import modules and packages into your Python code using the import statement. The import statement specifies the name of the module or package you want to import, making its contents available in your current file. You can also use the from … import syntax to import specific functions or classes from a module, or from … import * to import everything. Aliases can be created when importing using import X as Y.
What is pip, and how can it be used to install external packages from the Python Package Index (PyPI)?
pip is the package installer for Python. You can use pip to install external packages from the Python Package Index (PyPI), which is a repository of third-party Python packages. To install a package using pip, you can use the command pip install package_name in your terminal. pip will download and install the package and any dependencies it may have.
How can you read data from and write data to files in Python, including working with spreadsheet files using external libraries like openpyxl?
You can read data from files in Python using the open() function to open the file and then using methods like read(), readline(), or readlines() to read the file contents. You can write data to files using the open() function with the ‘w’ or ‘a’ mode and then using the write() method to write data to the file. For working with spreadsheet files, you can use external libraries like openpyxl, which provide functions for reading data from and writing data to Excel files. openpyxl allows you to load workbooks, access worksheets, read cell values, and write new data to cells.
Comprehensive Introduction to Python Programming
This Python course covers everything needed for a beginner to get started with Python.
Here’s a summary of the course content:
Introduction to Python: Includes Python’s advantages, flexibility, and multi-purpose nature.
Basic building blocks: Covers important data types (strings, numbers, lists, sets, dictionaries, booleans), variables, and functions.
User input and validation: Writing programs that accept user input and validating it using conditionals.
Error handling: Using “try…except” blocks.
Loops: Utilizing “while” and “for” loops.
Modularizing programs: Writing modules and using built-in Python modules.
Demo project: Writing a program that accepts a goal and a deadline as user input and outputs the number of days remaining until the deadline, using the “datetime” module.
Packages: Explanation of packages versus modules and usage of external Python packages.
Demo project: Automating tasks for working with spreadsheet files.
Object-oriented programming: Learning about classes and objects.
Final demo project: Communicating with other applications over the internet by making a request to fetch data from Gitlab API.
The course also includes information on:
Setting up a local Python development environment: Installing Python and a code editor (PyCharm).
Integrated Development Environments (IDEs): Using IDEs like PyCharm for syntax highlighting, error highlighting, and code suggestions.
String concatenation: Combining text and numbers.
Variables: Defining and using variables, naming conventions, and reserved words.
Functions: Defining and calling functions, input parameters, and global vs. local variables.
User input: Accepting user input with the input function.
Data type conversion: Changing a value from one data type to another (casting).
Conditionals: Using “if,” “elif,” and “else” statements.
Error handling: Using “try” and “except” blocks.
Loops: Using “while” and “for” loops for repetitive tasks.
Lists: Creating, accessing, and modifying lists.
Comments: Writing comments for code documentation.
Sets: Creating and manipulating sets.
Built-in functions: Overview of useful built-in functions.
String functions: Using built-in string functions.
Dictionaries: Creating and using dictionaries.
Modules: Structuring code using modules.
Built-in modules: Using built-in modules like “os,” “logging,” and “datetime”.
External packages: Installing and using external packages.
Spreadsheet automation: Reading, writing, and manipulating spreadsheet files using “openpyxl”.
Object-oriented programming: Defining classes, creating objects, and using methods.
API requests: Interacting with external applications using API requests.
Python Data Types: A Concise Overview
The Python course introduces several key data types. Data types are a fundamental concept in programming because the data type influences what can be done with the data. Here’s a discussion of data types covered in the course:
Strings: Used for text. Strings are usually represented within double quotes, but single quotes work as well. String concatenation, using the plus sign (+), combines multiple strings.
Integers: Used for whole numbers, including zero and negative numbers.
Floats: Used for numbers with precision, such as currency or weight.
Booleans: Represent True or False values, often resulting from a conditional check.
Lists: Used to store an ordered collection of items, which can be of any data type. Lists are defined using square brackets []. Lists allow duplicate values. Individual elements of a list can be accessed using their index, starting from zero. You can add elements to a list using the append function.
Sets: Similar to lists, but sets only store unique values. Sets are defined using curly braces {}.
Dictionaries: Store data in key-value pairs. Dictionaries are also defined using curly braces {}. Values in a dictionary are accessed using their corresponding key.
The course notes that knowing how to check the type of value can be useful, and this can be done using the type function.
Also discussed is that each data type has its own built-in functions. For example, string values can use functions like split and isdigit. Similarly, lists have functions like append and remove.
Python String Concatenation Techniques
The Python course covers string concatenation, which is the process of combining multiple strings.
Key points include:
Using the plus sign (+): In Python, the + operator is used to combine strings.
Explicit string conversion: When combining strings with numbers or other non-string data types, it’s necessary to explicitly convert the number into a string using a function that looks like this: str(number). Python does not automatically convert numbers to strings in concatenation.
Elegant Syntax with f-strings: Python offers a more readable and cleaner way to concatenate strings using f-strings. By prefixing a string with f and using curly braces {} to enclose variables or expressions, you can directly embed their values into the string. For example: f”20 days are {20 * 24 * 60} minutes”. This syntax requires Python 3.6 or later.
String literals: Any character within single or double quotes is interpreted as a string, including space characters.
The course notes that f-strings are a newer and more elegant way to handle string formatting in Python.
Python User Input: Capturing and Validation
The Python course includes detailed instruction on how to handle user input.
Key concepts:
input() function: The input() function is used to accept input from a user. It takes a string as a parameter, which is displayed as a prompt to the user. The program waits for the user to enter a value and press Enter.
Input as a string: The value entered by the user is always treated as a string, even if the user enters a number.
Prompts: It is good practice to provide a clear prompt to the user, so they know what type of input is expected. Newline characters (\n) can be added to the prompt string to ensure the user input begins on a new line.
input function example:
input(“Enter a number of days:\n”)
User Input Validation
Since the input() function returns a string, it’s important to validate the user’s input.
Here are the key points regarding validation:
Data type conversion (casting): If the program requires a number, the input string must be converted to an integer or a float using int() or float(), respectively. This conversion is also called “casting”.
Error handling with try and except: To prevent the program from crashing if the user enters an invalid input (e.g., text when a number is expected), use a try…except block. The try block contains the code that might raise an error, and the except block contains the code that will be executed if an error occurs.
Validating input type with isdigit(): Before attempting to convert the input to an integer, the isdigit() method can be used to check if the string contains only digits. However, isdigit() returns False for float numbers and negative numbers.
Conditional checks: Use if, elif, and else statements to check if the input meets certain criteria (e.g., positive number, within a specific range).
Validation examples
Checking for digits:
if user_input.isdigit():
# Code to execute if the input is a digit
else:
# Code to execute if the input is not a digit
Using try and except to handle potential ValueError:
try:
user_input_number = int(user_input)
# Code to execute if the conversion is successful
except ValueError:
# Code to execute if the conversion fails
Continuous Input
while loops: To continuously prompt the user for input until a specific condition is met, a while loop can be used. For example, the program can continue to ask for input until the user enters “exit”.
Breaking loops: The break statement can be used to exit a loop prematurely if a certain condition is met.
while loop example:
user_input = “”
while user_input != “exit”:
user_input = input(“Enter a value (or ‘exit’ to quit):\n”)
# Process the user input
Python Tutorial for Beginners – Learn Python in 5 Hours [FULL COURSE]
The Original Text
hello and welcome to this python course in this full course you’ll learn everything you need to get started with python python is the most popular programming language out there and is used for so many different industries like web development data science machine learning or generally for writing automation programs to automate repetitive tasks so learning python is definitely a good idea let me give you a short overview of all the topics i’ll cover in this course after giving a short introduction to python we will start with the basic building blocks of programming the most important data types like strings numbers lists sets dictionaries boolean data types etc and how to work with them learn about variables and functions and why we need them write a program that accepts user input and learn how to validate the user input using conditionals error handling with try accept and also learn loops with while and for loops and again why we actually need them you will learn all these concepts with hands-on examples as a next step you will learn how to modularize your program by writing your own modules and then see how to use some built-in python modules with all this knowledge we can then build our next demo project to write a small program that accepts a goal and a deadline as user input and then outputs the number of days remaining till the goal deadline within this exercise you will learn how to use the date time module to work with dates after that you will learn about packages and comparison of package versus module and we will use an external python package in our next demo project in which we will automate some tasks for working with a spreadsheet file finally we dive into object-oriented programming you will learn what classes and objects are in programming and python specifically and why this concept is so useful in the final demo project you will learn another common use case with python which is communicating with other applications over the internet by making a request to fetch some data from gitlab api in this specific case we will list the gitlab projects of a specific user so that’s what we’re gonna learn if you like this course don’t forget to give this video a thumbs up i’m really excited to teach you all of these so let’s get started first of all python is a programming language just like java or javascript python compared to other languages has two very big advantages first of all it’s easy to learn it has a simple syntax and it’s very easy to set up and get started with for example compared to java where you need some initial configuration before you can even start your application but it’s equally or even more powerful than java now what makes a language powerful or how can i say that python is more powerful well that comes from the ecosystem which means libraries and modules that python developers themselves develop but also external developers create and maintain so the more people adopt the language the more powerful it gets because new libraries and so new functionalities get added to it and the second advantage is that it’s flexible now what does a flexible mean in this case what makes a language flexible it is easy to mold to your wishes so you are not limited or restricted by the language specifics like syntax or data types or some other constraints or even library functionalities you can extend python widely and as one of the results of this flexibility python also became a multi-purpose language meaning it is used for many different categories so let’s see what these categories are first you can use it to write web applications the popular libraries for that are django or more lightweight flask python became extremely popular because of the rise of data science machine learning and artificial intelligence industries and more and more libraries were created and are still being added for python for all these categories they are very popular and highly used libraries for data analysis and data visualization libraries for artificial intelligence projects for things like face recognition voice recognition and a bunch of very powerful and widely used machine learning libraries python is also often used for data collection like scraping the web creating web crawlers that are basically programs that collect data from internet which you can save and then process later again many different powerful libraries to do all of that and finally automation with python python has many great libraries to automate devops tasks for example starting from ci cd pipelines to cloud platforms and monitoring your infrastructure etc you can also write python scripts to do automated backups cleanups on the servers etc in addition to devops tasks you can also automate just general tasks with python like when working with excel sheets which is a common use case in many big companies or automating some tasks on your own laptop and there are also libraries for mobile development gaming desktop applications but these are less likely use cases for python because there are better alternatives for that so you see that the use cases for python are pretty vast and it actually spans several industries and it’s mostly concentrated around data analytics machine learning and automation areas and note that this isn’t the case for many other programming languages usually one programming language is good for just few things and you should use something else for other use cases so now you see how useful python knowledge could be and how it can help you in your job but also make you more valuable at your work and for your entire team i hope you are already excited to learn python so let’s get started as a first step we’re going to configure our local python development environment so the first thing we need is install python locally on our laptop so first we install or download python package for your specific operating system and then basically just click through the installer wizard to install python locally on your laptop and note that if you’re doing this on windows very important step in the installation process would be to check the ed python to path option basically that you see here because by default it is unchecked and you have to check mark it so that after the installation you’ll be able to execute python commands in your terminal now an interesting note here if you’re using mac os like i do is that by default on mac os there is python already installed so if i do python version and execute i see that python version 2.7 10 is installed and that is actually python that mac os the operating system itself is using however for our tutorial and generally when working with python we want to be using the newest version which is python 3. so we’re going to leave that default python installation alone we’re not going to use that or touched it and instead we’re going to be using the python version 3 that we just installed locally so now if i clean this up and we want to execute python version 3 commands we’re going to do python 3 instead and version and that will give us the version so that’s how we can differentiate between the already installed python and the newest version that we just installed so just be aware of that difference now that we have python available locally it’s time to download a code editor for python because we’re going to be writing files with python code so we need a proper editor for writing python code and actually the best python code editor available out there currently is pycharm which is from jetbrains so that’s what we’re going to be using throughout our tutorial so let’s go to pycharm it is an intelligent code editor which makes it much easier to write code so it makes you actually very productive when writing code and we will see why throughout the course as you can see there are two versions we have the community version and professional one community version is free and already has a lot of powerful features but the professional edition gives you additional very useful features especially if you’re creating web applications or scientific projects in python so with professional version additionally you will get scientific tools that you can use in scientific projects with python but also you get support for python web frameworks and database integration which can be of course very helpful if you’re developing web applications if you want to get the professional edition jetbrains actually provided me with a code for my channel to try it out for three months for free just use my code when you install it but for this demo community version is absolutely fine so i will go with this one and install it and just click download and once the pycharm installer is fully downloaded we can just click on it move it to the application and now i can actually use it locally so i’m just gonna open the application and we’re gonna take a quick tour around pychar it’s actually pretty simple to set it up and there you go we have our pycharm and we can now create a new project and let’s call it my python project and that’s it basically we don’t need to change anything else and here you see the location basically of where this application folder will be created you see pycharm projects folder got created in my users directory so this is basically very convenient because all my pycharm projects or my python projects that i create using pycharm will be created in one location and here you also see that python version 3 that we installed is automatically being used for this project which is exactly what we want and you see it says base interpreter and python interpreter is basically a program that knows how to execute python code it will know how to interpret or translate our python code into instructions that computer can understand so with this configuration we don’t have to change anything we’re gonna create our project so first of all i’m going to make all this a little bit bigger so that you can see the menu here on the side and the code a little bit better so in preferences editor font we’re going to set the size to 20. if i apply this right here you see that this code editor font basically got bigger and i also want to increase the size of this menu font here so in appearance i’m going to set it to maybe 18 and there you go so basically everything is bigger now so you can follow along and see exactly what i’m typing and also another note here if you want to configure your theme basically so if you don’t want it to be dark or maybe you want some other color scheme then you can select it here in appearance you have four themes available let’s actually try this one out and apply and there you go you have a different theme i actually prefer this one so let’s leave it at that so as you see we have a very simple project with one main main.pi file the extension is for python files which basically contains very simple code and we’re gonna basically just remove all of these and start from a clean python file state and in the next section we’re gonna dive right in and write our first simple python application we’re gonna start with the simplest example in python to basically learn python syntax and get started as simply as possible so first of all we’re gonna write a very simple application that just prints some output and in python when we want to print basically display results of what we wrote we use this syntax where we say print and here we can pass in basically whatever we want to display and now if i want to see whether this super simple application works i can run it or execute it with this triangle here and i have the output so the basically the output is displayed or printed right here and i see the output is 1. i can display some other values like 200 and run it and there you go let’s say we want to display some text basically whatever some sentence and again triangle and we have that output here right so again very simple example of writing python code that basically displays some information when we execute it one thing that i want to note here is you see that we write some code basically in this window right here so in our main.pi file and when we run it or execute it our code we see some display in this window so you may be wondering what is this window and why do we see some output right here the answer to that is that whenever you’re working with tools like pycharm which basically have all the functionality that you need to write your code and then execute your code you basically have everything in one place so whatever we write we can execute or run right away now without such tool how would we write code and how would we execute that code and this will help you understand what’s going on here and to show that i’m going to go back to my terminal and i’m going to create a new file and i’m going to call it test dot py we’re going to write the same code basically in this file you can do it in a file editor i’m just doing it directly in the command line and save it so now we have the same identical file as here but not inside our code editor right not inside this pycharm tool and we have python 3 available locally so now how do i actually execute a python file outside this pie chart i can do that using python 3 test dot p y and if i do that i get the same output in the command line so basically what you see right here this whole thing is integrated so basically all in one place where you can write your code the editor right here where you can navigate your files in your project so basically this is just a folder on your laptop and you can navigate the files here and you have the execution environment at the same time so you have to go to terminal and execute python 3 whatever you have everything in one place and tools that provide you with this type of environment for different programming languages for python it happens to be pycharm these are called ides which stand for integrated development environment integrated because you have everything in one place so you don’t need to use terminal but in addition to this integration you get more cool features which helps you in writing python code for example syntax highlighting highlighting errors or code suggestions autocomplete suggestions and we will see those cool features actually also throughout this course so basically just makes your life as a developer easier however it’s good to understand that connection between executing your files on the terminal when you don’t have such a tool versus executing and working on your application inside that tool awesome so let’s get back to our code editor a file where we write our code and till now we have done something really simple like print a text basically and print a number right and this leads to the first concept in programming languages which are data types so in python just like in any other programming language you have data types for text and numbers the text data types are called strings so everything within the double quotes is basically a string but note that in python you can also use single quotes for strings so double quotes or single quotes they both work the same and there’s actually no difference between them and for numbers we actually have different data types so for whole numbers like 2 20 but also 0 and negative numbers as well we have a data type called integer and that’s also how it’s called in most programming languages however you also have numbers for currency for example how much a product costs right so if you have an online shop you would have prices like this for example so these are basically numbers with precision this could also be for example when you’re shipping something you could have a weight of a package that is also not a whole number but has a precision so this type of numbers in python and many other programming languages are represented as float data type so again you have integers and float data types and if we execute that you basically see all of that printed as we wrote them now obviously printing values like numbers and text like this doesn’t make much sense unless we’re getting some useful information from our simple program right here right so let’s do something more useful with python now let’s clean all this up and let’s say we want to do some calculations very simple logic that basically calculates how many minutes there are in 20 days so we have 20 days which have 24 hours per day which have 60 minutes per hour so this line will give us basically calculation of minutes for 20 days and there you go that’s our number now this makes a little bit more sense because now we have a program that actually does something for us so basically as you see you can do any math operations on numbers in python and again in many other programming languages you can do plus minus division whatever just like you know it from basic math however i want to note right here something that many people think about programming and maybe are misinformed about which is if you’re doing web development or maybe devops automation with python and not something like data science or data analytics this is probably an example of the highest math knowledge that you need for programming in python because even though we’re going to use some calculation examples because they’re just good as examples to show you the basic concepts of python you do not really need any advanced or even intermediate knowledge of mathematics when programming because it’s really not about meth however what you need is logical thinking and we’re going to be doing some of that and see that as examples so just bear that in mind in case you are misinformed about that so back to our example we have this number that is displayed here as a result however maybe if we use this program we don’t remember or we don’t know what this number stands for if somebody else is using so we want to add some descriptive information about this number that says this is how many minutes there are in 20 days so basically we need a line that says 20 days are this many minutes and this should basically be exactly this calculation right here so how do we put this calculation basically right here in the middle so that we end up with this whole phrase displayed right here so how do we combine text and numbers basically or calculation of numbers and in programming languages again this is not specific to python we would do that using something called string concatenation and string concatenation is basically a fancy word for gluing together or combining multiple strings now how does the syntax for that look like we combine the strings using plus sign so apart from adding numbers obviously using plus plus is also used in programming for combining multiple strings so in our example we have three string values and we want to put them all together in one string or one sentence we have the first string 20 days r and then we have the second string minutes and in the middle the third string which will be the value of the calculation however if we just put a number here python interpreter tells us it’s not a string it’s a number so we need to turn it into a string other programming languages do that automatically in python we need to do that explicitly so we need to tell python take this number but not as a number but as a string and we do that using a syntax that looks exactly like that so basically we have a non-string value but we’re telling python we want it as a string because it needs to be printed out as a text basically so if i execute this line let’s see what happened and there you go we have our output just like we wrote it here but you see that there are no spaces around so basically 50 is just really glued together without any space around and how do we put spaces around these 50 basically add a space here add a space here now why does that work because this whole thing for python is a string again because we are putting it within these quotes so basically any character that you see on your keyboard right now if you put it between those quotes is interpreted by python as a string including this space character right so if we execute it again we have spaces around 50 and our sentence our phrase looks fine and if you’re thinking right now this is actually kind of annoying because first of all it looks ugly and also there’s a high chance you’re gonna forget it that is absolutely right so in python again specifically there is a way to do it in a more elegant way using a different syntax and the more elegant syntax for that let’s actually close this is print and let’s write that again and instead of having these plus we have curly braces and we write our number inside or whatever non-textual value and at the beginning right here basically before we start writing a string which starts with quotes we just write the letter f and you see the syntax highlighting as well basically sees that this is not part of the text this is non-text value and if i execute it i should see the same output from the second line and this is really a way cooler way to write this instead of using plus but this is something very common and also something that you would encounter in most programming languages so just important to know that this is a syntax for string concatenation as well so we can basically just remove it and use this syntax for our examples and also note that this syntax is actually a new addition to python so it only works if you have a latest python version in our project if you remember we actually configured and chose version 3.9 and that’s why it works for us if you use python 2 for example python version 2 this syntax is not going to work for you we can actually demonstrate it so i’m going to copy that line and i’m going to change our test.pi and now if i execute it using my python 3 you see it works fine if i do it with python which is version two point something let’s see what happens there you go syntax error invalid syntax because python version 2.7.10 so older version basically doesn’t recognize this syntax so just be aware of that so this syntax actually only works for python versions starting from 3.6 so everything below that every python version basically will not recognize this syntax as we see right here so again back to our code and now we just have a number here but what we actually want is the calculation for getting the correct result right so we want again 20 days in hours and then in minutes and if i execute it you see that the calculation was done and here we have the full complete sentence with the result in it and if you’re curious this f actually stands for format so this is basically formatting our text or our string in a correct way awesome so we have this line of code here that basically calculates for us how many minutes there are in 20 days let’s say we want to do the same for 35 days right what we can do is basically copy that line and replace the values for 20 with 35 and if i execute it i get the same calculation but for 35 days and we can do that basically multiple times for different values so let’s say we want it for 50 days and we want the same calculation for i don’t know let’s say 110 days doesn’t really matter and we have obviously different number of minutes for each of these values and now let’s say we wrote this program it’s ready and we’re using it and at some point we decide you know what i want this program to actually calculate how many seconds there are for these provided days instead of minutes so what we would need to do in that case is basically change the calculation in all those four lines so instead of minutes it should actually calculate number of seconds in a day right so we have the hours minutes and seconds and we would have to change the text as well here and we would need to do that for each one of those lines right so we would have it here like this and again if we need to modify this for hours or milliseconds or whatever we basically have to do these changes multiple times right even though if you actually look at that this is the same exact calculation for each line that doesn’t change right if you want seconds then this is the calculation that you need to do so how can we actually avoid repeating the same calculation and the same text in our code and the answer to that is variables so in programming languages we have variables that basically hold values that will repeat throughout your code that you can set once and use it in multiple different places so instead of basically repeating this calculation four times we basically do this calculation once like this and we basically save this value in a variable so that we can use it whenever we need right and the way that variables are defined in python is variable name let’s call it two seconds equals and whatever that value is that repeats itself and that we want to save into a variable now i want to make two notes here regarding the variables in python first of all in python defining or creating a variable and giving it a value like this syntax for that is actually very simple compared to other languages because you just have the variable name and the value in many programming languages you actually have to define here some kind of data type for that variable for example if it’s a number like float or integer or string etc in python you don’t have to define that you just have name of the variable simple as that the second one is the naming convention or standard for the variables so we have two words for example if we name our variable calculation to seconds right we have actually three words here so variables that are descriptive so basically they tell you what this value actually is about so they have multiple words in them you can separate them using these underlines again in different languages the naming for variables can be different in python this is actually one of the standard ways of defining variable with underscores which i find pretty nice and easy to read so we’re gonna use this syntax basically throughout the course it will be totally and absolutely okay if we wrote it like this or if we used capital letters instead but again this is probably the most readable form and this is what we’re going to use now here note that we can decide whatever name we want to give our variable but in python there are some specific words that have special meaning to python these are called reserved words so you can’t use these words as variable names and we will use some of these reserved words throughout the course so you will see some examples great so we have our variable defined here and this is the value that this variable gives us so how do we replace now these repeating values with this variable so we’re going to delete that and again inside we’re simply going to copy the name of the variable so let’s execute and as you see we have our value printed just fine and we’re going to do the same for all those values and again execute everything works just like before now you may be thinking if we change this to minutes we would have to change the variable in all these places so that’s our case we can basically just rename our variable something more generic so let’s say calculation to units and this could be now any unit that we want second meaning it doesn’t matter and this is exactly the advantage of variable because you can name it whatever you want which basically just describes what this variable is about and now you won’t have to change that again and we can also replace this one here accordingly since it’s a text we can call it a name of unit we can also call it unit doesn’t really matter we’re the ones deciding what that variable name is and once we have that variable we can now replace it here how do we do this because this is actually part of a text a string the same way we did right here we’re gonna delete that and create an expression create a syntax that basically tells python hey this is not a string this is a non-string value and you already know this could be either number or variable itself and so we’re going to use the curly braces and the name of the variable and just like that we have substituted these values here and if i execute it works perfectly fine and we can do that in all four lines and our code is still working and this syntax right here with this format at the beginning basically prevents us or avoids basically saves us from having a bunch of plus signs here and then space characters etc this all looks way elegant now and now if at some point we actually decide you know what i want this program to calculate how many hours there are in the given days instead of seconds and we want to change the program to do that we could basically just change the calculation here and instead of seconds we have hours and if i execute there you go we see the changes right away so this is why when you’re programming doesn’t matter in which language including python using variables will be probably some of the most frequent thing that you do because you always have values that are repeating themselves and you want to write clean code so you create variables and one of the best practices when creating and using variables is as we’re using actually here is to name your variables so that you later and also other programmers who are working with you understand what this variable actually does or what type of value it actually has because if you just look at 24 you would probably not know what this 24 is about right but with variable you actually know that this actually represents a number that is used for calculating units right it could also be more descriptive like units for days but generally another advantage of variable is to basically describe that value as well that you’re using in your code now another thing you probably also noticed is that even though we’re using variables here so that we don’t have to change those values in four different places a lot of these four lines are actually pretty similar the only difference in those four lines are actually these numbers right here everything else is exactly the same so what if instead we wanted to make this code cleaner and basically avoid this type of duplication in our code right so for example if we did this for 10 different values we would have the same line this long line basically 10 times right so how do we avoid this type of duplication so right here we actually avoided duplication for specific values right piece of string here a whole calculation here but how do we actually avoid duplicating a whole line right the whole piece of code basically which has multiple different stuff in it not just a value and we do that using functions so functions are basically blocks of code like this right or basically logic in code that does something it’s not just simply a value but actually does something more complex that is again used in order to avoid repeating the same logic or most of the same logic in your code so how do we create functions just like we created variables here we create functions and the way we do that is using following syntax right here let’s create our first function we start with def so we define a function just like we define a variable but for function we need this keyword basically called def and now we can give our function a name just like we gave name to our variable we can give our function a name and here we can use the same standards like for variable we can name the function something descriptive something that actually says what this function does and let’s call our function days to units and then we have the brackets and a column so this line basically defines a function it tells python hey whatever comes after this is actually going to be a block of code that is going to be referred to or is going to be named these two units and how do you write a function i’m just going to copy this one actually here and let’s give us some space and again this is very specific to python we need to indent here with spaces and i’m going to paste in what i copied inside these two lines basically tell python this piece of code or this line of code because we just have one line here belongs to a function called these two units and again we just have one line but this could be function with hundreds of lines right so i can write whatever i want the next line all good and then i can do some calculations and i can basically write whatever logic i want here and all these will belong to this function so now this logic is inside a function that is called these two units and we can actually get rid of this and test our function and here if you noticed we have this yellow line under the function name that’s actually a warning for our code style it says we need two blank lines before so pycharm has a built-in official style guide for python that tells you how to style your code or how to write your code correctly now why is code style important well just like you write code you need to read code from other developers or your own code to understand what the code is actually doing so it’s important that code is easily readable and this is just another example of how an editor like pycharm helps you to write code so to fix the warning we’re just going to add a new blank line before the function definition so now what happens if i execute this block of code i have the variables defined here that i’m using in the function and then we have these two print statements so what happens if i execute now and as you see in the output here there is no output right nothing actually got printed so what actually happened because we have those two print statements that we defined in the function but we don’t see anything in the output and the way it works is whenever you create a function or define a function like this you actually have to use that function right again this is a similar concept to variables we have created variables here and we’re using that variable in our code the same way we create a function and we need to use that function how do we use a function or in programming languages it’s called calling a function or executing a function and we do that using the name of the function like this and as you see in the suggestion as well using brackets like this so this syntax here basically is what we call calling the function that we defined right here or using that function so now if we execute it there you go you see that those two lines got executed and we have the results here so we’re creating variables and we’re using that here we’re creating a function and we’re using that function here and note the difference between using a variable and using a function python knows this is a function because we are providing these brackets at the end right that tells us we’re making a function call basically but as you see now we have these 20 days so this only works for 20 days right what about other values that we had what about 35 days and 100 days we haven’t de-duplicated that right we have just one case here so how do we use functions so that everything else except for these two values right here actually stay the same and we do that in programming by giving our functions some kind of input value which are also called parameters so instead of having this 20 basically here hard coded as we said here and here we provide that value of 20 or 35 or whatever that value is basically whenever we use the function so we are telling python use these days to units function with a value of 20 or use that function with a value of 35 and way we define this input parameter in functions is very simply by defining this parameter between those brackets right so this is where the input we as programmers define the input parameters so right here how do we define that using our already familiar variables so basically right here i’m going to define a variable and i’m going to call it whatever i want i’m going to call it days or number of days but i’m not assigning a value to that variable right like i did here because i want it to be assigned whenever i use the function so this basically tells python that a function these two units can be used using one input parameter which is called num of dates right number of days so now the last part which is remaining is replacing these values using this variable right and just like we do it in these two places where we’re also using variables defined here exactly the same way we’re gonna remove this and define a block for non-textual value and we’re gonna put our variable num updates here and also here so you see now that our function actually doesn’t have any fixed numbers in it instead we’re using variables we’re using two variables that are defined outside that function and we’re using one variable that is defined within that function right this variable actually belongs to that function and now as you see whenever we want to use that function we’re telling python hey call this function called days to units with a parameter an input basically of 35. so now if we execute it by the way we can also do it here you see 35 days are and the calculation was done here and hours and now if we go back to our previous example where we wanted to calculate these for four different values right for different number of days we can actually do the same so we had 20 then we had 50 and we had 110 right so this basically gives us exactly the same logic that we had previously but with different syntax right so you see the difference that instead of having this basically four times we have much cleaner syntax where we actually see what this logic is doing which is days to units and then we have the number of days that we pass or give our function as parameter and if i execute this you see that it was printed four times for all different values we can actually remove this line and now if we make some change in our function for example we change the name of this variable we want it to be hours instead of units we just do it once in one place and that’s basically it so whatever changes we make inside that function and that is actually the big advantage of using functions in code whatever change we make inside here it doesn’t affect how we use the function because for using the function we only need the name of that function and the input parameter now probably you’re wondering what happens if i do not give my function a value let’s delete those lines and let’s say we do not provide any value here and we try to execute or call our function without the parameter and let’s execute and you see that python interpreter is complaining because we have told python here is a function called these two units and whenever i want to use that or my colleague another programmer wants to use that function they have to provide an input value here right so now whenever python sees the usage of that function and there is no input parameter that we are giving that function it cannot execute that function right because basically this value is missing here right and that’s why we get an error which also says missing one required argument so as you see whenever we define a function with a parameter with input parameter we have to also provide that input parameter another thing that you may be also wondering is what if i want to provide multiple input parameters to functions how do i do that it’s actually very simple you can do that by simply defining here another input parameter separated by comma and let’s say we want to pass here something that we want to print out additionally like a custom message doesn’t really matter and the same way exactly the same way as the first one we can actually use it in here we can even create a new line and basically just print out that message right and note that if you are using a variable without stream so basically it’s just the variable itself we’re not using any text in that case you don’t need this format right so you can basically just print it out directly and now again we have told python i have this function and two input parameters are required so i also need to pass to input values whenever i use that function so now let me just pass in some custom message let’s say i’m happy about the calculation or i know i’m going to be happy so let’s say awesome and let’s do another calculation and this time i say looks good and if i execute it you see that i get awesome the first time and then for 35 i get looks good so you can basically define and provide as many input parameters as you want common practice and also what you will see in just normal code basically is just a handful of input parameters maybe one or two so it’s not actually overloaded with 10 parameters cool now that we know functions and variables why they’re used or why are they useful and how we use them there is one point that i want to mention which is variable scopes in functions what does it mean as i mentioned previously in this function we’re using multiple variables right we’re using two variables that are part of the input right that we provide when using a function and we’re using two variables that are defined outside the function right somewhere else in the code so variable scope basically means where is the variable that function uses defined and variable has a global scope for a function if it is defined outside the function like these two variables right here could be completely in a different file not even in the same file where the function is so these are global variables so all the functions that you have in your python code can use those global variables and then you have local variables local variables are variables that are created within that function right so these two variables are basically only available inside that function because it was created within that function so internal scope and global scope so that means that when we create another function let’s call it scope check because that’s what we’re going to do we want to test the scope in this function i can access the global variables like name of units but i cannot access the internal variables like number of days and let’s actually test that so i have num of units which is a global variable defined here outside the function and the second one i have a variable that is defined inside another function right so as i said internal and as you see right here we already get a red line underneath that says unresolved reference num of days so for this function basically that variable is not visible it’s not accessible it doesn’t exist basically at all and we can even test it out actually so again if we want to see the results we have to actually use that function like this run the function and if i execute it you see that we get an error that says name num of days is not defined right it doesn’t know that there is a function like that anywhere in code however it does recognize the global variable and that means that variables defined outside function itself global variables are accessible to all the functions and if you have variables defined inside the function then they’re only accessible for that specific function and not for other ones and that means actually that if num of days variable does not exist for scope check variable we can actually create a variable inside scope check with the same name and we would have basically no problem at all so this is not going to be a duplicate because this function doesn’t know about this variable the number of days here and scope check doesn’t know anything about variable num of days right here and if we want to use that function now we have to put provide the value let’s do 20 and if i execute there you go you have name of units and the 20 that we provided so global variable local variable defined here another interesting thing is that as i said inside the function body so to say so this is basically whatever is part of the function right in this indentation is called function body so we can create whatever logic we want inside that function body so whatever i can do in python generally i can do inside the function body so one of those things is actually creating variables right just like we created variables here we can create variables here like this let’s call it myvariable and variable inside function and we can print that out as well so now we have three types of variables that we are using in this function we have a global variable we have internal variable that is passed in as a parameter and we have internal variable again that is basically defined so the variable isn’t provided when we use the function but it’s basically just defined inside the variable and again if i execute this see hours num updates and variable inside function text printed out like this and obviously this is just for demonstration but we’re going to see more realistic examples of that in our projects so i’m going to clean this up and we can move on to the next concept so now let’s go back to the example where we calculate number of hours and we do that for four different values now if you want this application to be really useful for us or somebody else it doesn’t help that we have to fixate here just four different values right the application should be able to take any value that we basically fit it right so we should be able to provide any number of days and the program should calculate the number of hours in those days so what we need here is user input so when we give this application program to somebody else or use it ourselves it should allow some user input so how do we write a program that asks for and accepts a user input and then does something some kind of calculation some kind of other logic based on that user input accepting a user input from a python application is actually pretty easy let’s get rid of all of these lines first and we can do that by writing input and this will basically give a user a prompt to enter some input value now you probably already see from the syntax that this looks very much like using our days to units function right in this case with the parameter so input is actually a function that python provides us with so we didn’t have to write this input function right we wrote the days to units function but input function is available in python so that we can use it whenever we want and this parenthesis here tells python we want to call an input function and we’re calling it or using a function without a parameter so now we know that we can write functions ourselves for logic that we need but python has tons of functions that python developers already wrote and is part of python and we can use it in our code so that not everybody has to write their own input function logic and the code or the functions that python provides are again part of this python that we use in a project and obviously if you’re using the latest version of python you will get the latest code and latest functions that python basically provides so back to our function execution and let’s see what happens when we execute this program i’m going to run it and in the outputs you actually do not see anything other than my cursor is blinking here so it’s actually waiting for user input so i can actually type in something here so i can do 20 and enter and process finished with exit code so i was able to input something doesn’t really matter it could also be a string actually doesn’t really matter and program basically finishes so that’s the simplest usage of input however as you noticed here running this program and basically having this blank output here is a little bit confusing so if another user is using our program they will probably be wondering what’s happening here so what we can do is in input function we can provide a parameter that actually tells a user something right like enter a value for number of days or something similar so that it’s not just a blank prompt right so we can do that by passing in a parameter a string which is going to be our message so we can do a user enter a number of days and i will convert it to hours and here you see right now that the program wasn’t finished because we didn’t enter anything so this program finished line wasn’t output yet and that means the program is still running it is still waiting for our input and in pycharm in this ide if you want to terminate the program manually yourself you can click this stop button and as you see process finished so now we can run the program again and as you see here we already have a message that we’re displaying to the user so that they can enter the hours right and here we can provide our input 30 and there you go however this doesn’t look nice here we actually want the user to get a prompt on the next line how do we do that as part of a string we can actually add a new line or newline character basically and that in programming is actually represented by backslash n and you see a special highlighting for that one now let’s execute and you see that my cursor is on the next line now and again let’s provide a value enter and program ended so we have now a more user-friendly way of asking program user for their input instead of just showing an empty prompt and we’re getting user input now we’re not doing anything with that user input right that input basically just finishes the program and that’s it we’re not doing any calculation for that input so how do we use the value that user enters here when input function gets executed we do that and this is a very important concept by assigning whatever result this function usage gives us which is in this case user input assigning that result to a variable so right now it’s basically executed and it’s just wasted right it just disappears so instead we want to save that value that entered input value in a variable so that we can access it later and we do that by let’s call it user input variable equals so just like we created variables here with variable name and a value right or even an expression right if we did a calculation here that will be basically a whole expression whole calculation the same way we can use values that function execution gives us to assign it to a variable so now what i’m going to do is i’m just going to print the user input so that we can see what value that user input variable has so let’s execute again it asks for our input let’s put 20 and print user input gives us 20. so user input variable value basically becomes whatever we provide as an input now that’s a new concept and it could be a little bit confusing so let’s see another example with our own function what would happen if we assigned value of this to a variable we get a warning as you see here in the editor which is one of the great things about ides that it basically gives you warnings when something is not correct and the warning says function doesn’t return anything so basically if we want to have some value as a result of function execution we have to return some value in the function and how we do that instead of printing the value right away we can actually return that value using return keyword again you see special highlighting here just like here because return is a special word that python understands that you want to basically give back a value this value right here as a result of using the function right so you could have some logic here doing the calculation whatever and then as the last line you can return that calculated value and now the warning is gone because we’re actually returning something from the function and when we return value from a function again we can assign it to a variable so that we can use that value whatever function returned by referencing the variable and one of the usages will be basically just to print it just like we did before like this let’s delete it temporarily and test our program and there you go you see that this function got executed with input 20 this text this display text basically was put together in the function and was returned or was given back as a result and we saved that this whole string basically this whole sentence in a variable called myvar and when we print that myvar we see that value printed out here and again if we enter some other value we would get different text and again that is actually a very important concept of giving back some results from a function execution and you saw in our examples that you can have a function that doesn’t return a value just print something on maybe does something else or function that returns some value you can have both types so back to our example of user input so now hopefully it makes sense that input function returns whatever value the user entered as a result and we can save it in a variable and then access it later again let’s get rid of this line and now let’s actually do the calculation on the user input number of days how do we calculate number of days very simple by calling our function that actually does that so we’re going to call our function to calculate the number of hours for an input and the parameter that we passed in is going to be whatever the user provided so instead of basically hard coding a value here ourselves we give it a value that user provided instead so the num of days will be the user input and now again because this function returns the whole string it doesn’t print it remember it just returns it so when i execute this and i provide in some value that’s to 200 you see that i don’t have any output here because we didn’t print anything we basically just returned the value here we didn’t do anything with it so the last piece missing here is to display the text the string that function returns so we save that return value first let’s do calculated value so we save this thing in calculated value variable and finally we can print it and now let’s execute it and let’s see what happens i’m going to type in 10 10 days and let’s see what we get now and you see we have this weird value here as a result of the calculation so what exactly happened so this part of calculation basically which represents this number didn’t do a proper calculation and the reason for that is because the input value that we get with inputs function is always treated as a string and not a number so basically at this place here number of days inputs 10 here is actually treated as a text and not a number and where this weird result comes from is basically number 10 printed out 24 times so instead of doing the actual calculation 10 times 24 10 is printed 24 times and that’s what happens when this is interpreted as a string so how do we make python see that number see that input value as a number as an integer and not a text or not as a string and it’s actually pretty easy to do on the next line the user inputs again we saw right here it is a string so we have to make it into a number and we’re going to do that using int and user input and that process of turning a value from one data type into another is called casting if you remember we already saw an example of it when we turned a number into a string in the string concatenation example again from the syntax you should already know that this is a function call so we’re calling a function called int again that python itself provides us with because we didn’t write that function and we’re passing in one parameter which is a string and we should get an integer from that string as a result and we can save that number into a variable and let’s call it user input number and now we have 10 as a number instead of as a string and instead of passing in that string user input we can now give our function number that it expects let’s save it and execute let’s put in 10 and there you go now the calculation is correct what i want to show you now is how this user input actually works without a code editor like pycharm so i’m gonna copy all this code and let’s go back to our terminal and in our test dot pi i’m going to paste in our code and save and let’s now actually see how the user input works when we execute it in a simple terminal window and as you see here we have the message first and the prompt is right here so we can enter a value let’s do 25 enter and we have a result 25 days are 600 hours great so our program is working it is converting the number of days to number of hours and accepts a user input now what happens if a user enters an invalid value here so for example instead of a positive value for number of days maybe they enter a negative value like -10 for example and obviously that input value doesn’t make any sense but we are still calculating and giving a value right and this is another important concept in programming generally that when we allow users to give our program some input value we also want to restrict them and basically validate that what they provided as input is a valid value for our program specifically one that it makes sense like in our case -10 program still does a calculation but it doesn’t really make sense and second it doesn’t crash our program right so now let’s see what happens if we enter some text here you see that the calculation didn’t happen because we basically crashed the program application using that invalid user input does make sense or an input that crashes our application because the calculation isn’t even possible and we want to avoid users basically either providing a nonsense value or a value that will crash our application so we need to validate user input and this is again important concept in program because whenever you allow user input you always have to validate it so in this part we’re going to learn concept called conditionals and we’re going to learn this concept with an example of validating a user input so where are we going to do the user input validation we can do it in our function right before we actually do the calculation we can first validate is it a positive number and not a negative one so user gives us their input we convert it to a number and then we pass that number to our function so negative 10 positive 10 that is a number basically will be passed on to our function and right here we can check whether this variable value here is a negative number or not how do we do that we do that using if else conditional statements so very simple and intuitive to understand we say if number of days is greater than 0 means it is a positive number then we want to do the calculation and return all of this but you see that we have a red line here so basically whenever we use if condition we have to have a proper indentation so all of this line basically goes indented for this line kind of the same way as we indented the whole function body inside the function whatever logic and whatever code is right here indented below the if condition will be executed if number of days is really greater than zero so let’s try that again i’m going to execute it let’s put a positive 10 you see 10 days are 240 hours got calculated now let’s put -10 as an input and you see none basically no output for us because this line didn’t actually get executed for -10 input value now what if we want to tell a user hey this was an invalid value and that’s why we didn’t do the calculation instead of just showing none we can do that by returning this feedback message or error message whenever this is not true so whenever number of days is not greater than zero we want to return something else right another message and we can do that using else and the same way as for if we have the indentation and whatever we write here will be executed if number of days is not greater than zero so here we are gonna return you entered a negative value so no conversion for you and here it’s time for another special term in programming that greater than sign is called a comparison operator and we have three of them we have greater than less than and equals and these are called comparison operators because they are used in an operation to compare two values and before in this course we learned arithmetic operations like plus minus divide multiply so again fancy words for simple concepts but these are the official terms for these so now if someone mentions them you will know what they’re talking about so now let’s execute the application and let’s provide -10 and you see that this line was printed as a feedback to the user so let’s go through the flow again user gives us their input in this case -10 we convert it to integer so now it’s -10 integer and we pass it on to our days to units function and these two units function basically has this if else statement that’s how it’s called in programming and our if else statement validates or checks whether this input is greater than zero if it is then the function will return this as a result so basically the calculation with a proper message else so basically if this is not the case then it will return basically just a feedback message for the user and note that else doesn’t have such a check here we don’t check num of days is less than zero and the reason for that is because it doesn’t check for less than zero because it basically just decides if this is not true else or in that case just do this so we don’t need additional check here now this segment right here where we’re doing the check is called a conditional so basically we’re providing our program a condition if this condition is correct then do something otherwise do something else and that conditional can be true or false if we enter 10 then this conditional will be true because it’s greater than 0 if we enter -10 then this conditional will be negative it’s not greater than 0 and those true and false values in programming actually are represented by its own data type which is called boolean and in order to show it to you that this conditional either gives true or false what i’m going to do is i’m going to print this conditional right before i do the check so for a positive number input this should print true and if it’s negative so it’s not greater than 0 this should print false so let’s test it out first i’m going to provide positive 10 and right here you see true because this condition is indeed true and note that this is not a string that’s why we don’t need the quotes here so we can basically just put in the whole expression in a print function and now let’s do the same with negative 10 and you see false and as i said true and false values belong to its own data type in programming which is called a boolean and again we can demonstrate that instead of printing it out we can save it into a variable let’s call it conditional check and in python there is a function called type which checks or prints out basically a type data type of a variable or a single value so if we pass it so this will give us data type of conditional check and obviously if you want to see that result we need to print it so print the whole thing so it doesn’t matter what we pass in this point and right here you see class boolean so this conditional check here which has a value of true or false is of type boolean now there are two things that i want to note here the first one is that you see that i am calling a function here which is type and then whatever that function type returns which is basically this output here we are printing it so we have two function calls that are basically nested and that is absolutely fine you can nest function calls another example of doing this nested function called would be for example right here instead of assigning these to a variable and then passing it here we can actually save us that step and in the days to units function call pass it as a value so this is a perfectly valid syntax and you can do that you can nest in the function calls and you would not need this additional step and you can do that as many times as you want it just looks cleaner when you have that syntax a little bit separated and not have two three four function calls nested so that’s one thing and another thing is we just saw a class boolean type here and let’s actually see the same output for string and number so just for the demonstration let’s actually see the type of string and integer let’s get rid of this for a second because we just want to test so we’re going to print the type of a string which says this should be a string type and execute and you see class string and now let’s provide an integer you see class int and let’s provide a float and there you go we have float so this is a very handy way of checking the type and we’re going to need that actually in a later example so back to our application and one note about booleans and conditionals is that you’re going to be using a lot of those in programming because they’re really the major or the core part of writing any kind of logic in programming so you’re going to need if else conditions and statements and booleans in your application so it is a very core concept and we’re going to be using a lot of them in our coming examples so let’s get rid of this code right here and one note before we move on here is that the negative numbers are not being calculated because of this condition now what about zero let’s actually try that out so i’m gonna enter zero which is actually also valued that doesn’t make sense because zero days input obviously will give zero of any units so enter and right here you see a feedback to user that says you entered a negative value so no conversion for you and the reason for that is because this condition here number of days checks greater than zero which means that negative numbers and zero will not match this condition so they will basically give you this feedback but our message says you entered a negative value right when we entered zero what if we wanted to have a specific message for a user if they enter zero and a specific one if they enter negative value right we want to differentiate between those two how can we do that in the if else statement in programming we can have multiple conditionals so basically we can have multiple ifs so how do we do that first we check number of days is greater than zero okay great now we want to check whether number of days is equal to zero and we can do that using another if here and in python the syntax for that is el if which basically is a combination of else and if so if this is not true then we want to check another condition number of days equals 0. now you know the equation sign generally is this one right here however when we’re checking whether something equals to something else in programming that equation check is represented with two equal signs and the reason is because one equal sign is already used to represent assigning a value to a variable so not to confuse those two actions in programming we have two equation signs when we want to check whether something equals a certain value and just like here we execute some logic whenever this condition is true so in our case we want to tell the user you entered a zero please enter a valid positive number so now again to go through this logic flow if the input value is a positive number then function will return the calculation and the message if it’s not a positive number then we will check additionally whether it’s zero if it’s not zero then this is a last condition basically then we know that it has to be a negative number right so let’s test this out let’s enter a positive number there you go let’s enter zero you entered zero please enter a valley positive number and let’s enter negative one and everything works perfectly note that you can have multiple alif’s between if and else statements and again note that el if has a condition just like if statement else does not have any condition so this is like the fallback so if everything previously stated all the previous conditions did not match so they were all false basically then this is the logic that will get executed in that case great so we have validated input value for users and we may feel pretty good about our program because it doesn’t calculate anything for values that don’t make any sense however we still have a problem what happens if a user enters a text instead of a number so basically anything that is not a number value doesn’t really matter basically some text if i enter you see that our program actually crashed and this is actually a user input that we want to protect our programs from because we don’t want to allow users to blow up our application right so let’s see what happened it actually says that we provided an invalid literal literal basically means the text itself or a number so basically a value that we entered for int function that’s the problem so this function call basically just blew up because in function expects a value which is a string representation of a number so basically ind expects something like this or something like this it doesn’t expect my text or some text so our application crashed on some text input now let’s see what happens if i provide a number but a float number instead of integer let’s enter 19.99 and enter and you see the same error this function basically returns an error because it cannot convert float into integer as well so we have a problem here that whenever user enters anything which is not an integer our program will blow up so how do we avoid that so basically before the int function gets executed with an invalid value we need to validate this whole thing and stop our program before that happens so we need the validation before int gets executed and we can do that right here right so before that line gets executed we’re gonna do a validation and one way we can do that is using our familiar if else statement so we can say if user input is digit so again from the syntax you know this is calling a function but note that instead of calling the function like this so basically just stand alone we have the syntax where we have the variable dot and then the function name so instead of passing this as a parameter right here in the function brackets we are passing it as a parameter again but using this syntax right so each digit function will execute for user input as a parameter and again in if we have conditions so this will be either true or false it’s a boolean and if user input is digit it’s a number basically so basically this will filter out input values that are text so basically they’re not numbers and if the input is digit then we want to execute this line and also the rest of our application like this and if it’s not true so if the user input is not a digit we don’t want to execute anything in our application we want to stop the execution and want to tell the user this was an invalid input value i’m not doing anything with my program so that it doesn’t crash so else if not digit we are telling the user your input is not a number don’t ruin my program so now let’s actually test it so i’m going to execute and write some text and there you go so user input is digit was evaluated to false so none of these got executed instead the else block was executed and it printed a message for our user so we basically avoided our application to crash with this check and if we try a proper number it works and if we enter 0 for example the application will get executed and we will get our message from here so our application is more or less protected and we’re not allowing for a invalid input number you say not a valid number now we know that in programming there are different types of numbers we have float numbers as well so let’s actually see what ease digit function really checks so let’s actually try to provide a float number instead of integer which is not a proper valid input for our program so i’m going to type in 19.99 and you see that each digit is false for a float number so we got the same your input is not a valid number output for float number as well which is perfect it’s exactly what we need and now let’s actually try to enter a negative number and let’s see if each digit function returns true or false i’m going to enter and you see that else block got executed because is digit was false for a negative number so basically this function filters out a lot of the bad input for us to protect our application from bad user input and that also means that we don’t need a check for negative values anymore and by the way in python you can actually have if statement without an else at the end this will work perfectly fine and this could be our application however note that in programming we don’t put this type of logic directly like this basically outside a function as a common and best practice we encapsulate most of the logic basically in functions so as a cleanup for our code we can take all this and put it into a function so right here i’m going to create a function and let’s call it validate and execute or something like this and all the logic that i copied will be just simply pasted in that function like this so now we have the logic nicely encapsulated in its own function but as you know when we create a function we have to call that function otherwise nothing happens so we’re gonna call it right here we don’t have parameters and we don’t have to provide a user input because user input is a global variable so our function has access to it let’s actually test it out and it works and let’s provide some bad input and it works too so that’s actually a proper way of writing code having every piece of logic in its own function with a proper description for the function now as a next step i want to show you also a concept or something that you will encounter very often in code which is nested if else statements and i’m going to show that example by cleaning up our program a little bit so as you see here we’re doing validation in two different places so we’re validating user input here but also inside these two units function itself so what we can do is we can put all the validation in one place in this validate and execute function and basically have all the validate logic in here and let the days to units function just do the calculation and not the validation and this way our functions and code will be a little bit cleaner and more logically built so after we validate that user input is digit we convert it into an integer so right here we have an integer value of the user input so we can actually check whether that integer value is greater than zero or equal to zero and we can do that right here without passing it on to the days to units function and just like this if conditional we’re gonna do user input number greater than zero if that’s the case we want the calculation to happen so both of these lines will get executed only if user input number is greater than zero and else in our case if it’s exactly zero we want to print a message to user you entered zero and remember we’ve got the negative numbers already covered using this condition here so that’s the one remaining i’m just going to copy that and paste it right here variable is called user input number so we’ll fix that and we’re going to print out that message so that means we don’t need any validation right here we can simply do the calculation so to go through this logical flow of if else or nested e-files statements we have the first if right here also note that indentations for these if else so basically they are on the same line here same position and the nested if else or in our case alif they’re also in the same position so again first that’s the big validation the first one is is the user input digit in the first place if not we basically shut down the program we print out a message to the user and that’s it if it is a digit then we need additional validation is that digit a positive number or is it a zero so we do that additional validation using a nested ifall statement and basically this line gets executed only if it is a valid number and if it’s a positive number and because of that we don’t need any additional validation once the these two units function gets cold and you probably already think and notice that nested if else statements are not the most beautiful thing in the world they are pretty ugly actually and especially we have multiple of them or multiple else ifs in between the function may actually end up looking pretty bad so it’s not recommended to have multiple levels of these nested if else statements in your code to basically just keep it clean but as i said you will encounter it a lot in programs in application code because sometimes you just have to write it like this thing i want to show you here is something called a try accept in python so right here as you see we’re validating user input right and then we’re executing this part of code only if that condition is true what if we had logic here where there were multiple places where something could go wrong let’s say a function execution could basically just blow up because of a wrong input or even as an example maybe this is digit doesn’t actually cover all the use cases so maybe there is a value that user can input that will still blow up our program so instead of checking each such possible scenario using if statements and then doing the actual calculation once all those things have been validated what we can do instead is basically tell python something like try executing this part of code here and if something goes wrong so if any line any function call or any logic execution fails we want to catch that error and we want to control what happens with that error ourselves programmatically and then catch logic will be accept and we’re going to specify what type of value we want to catch basically using this block and the name of that error type is actually what we saw in the output when we provided some text and a float which is value error so that’s the error that we want to catch basically so again we tell python you know what try to execute this block of code here and if one of those lines in that code results into a value error then instead of just crashing the program basically catch that error and print out a friendly message to a user so let’s actually try this out and note that try doesn’t have any validation like if statement so when i entered some text here int function will actually be called with some text and it will result in a value error and this block will then handle that error so i’m going to enter and and you see that your input is not a valid number message got printed and the same will work for a float number that also doesn’t convert to integer and for a proper integer value it will work fine and again difference between if else statement and using try except is that you can cover multiple such errors with this whole try except block right so you don’t have to do the validation specifically and that is especially useful for cases where you can’t really validate something using if condition right if there is a chance that you might miss something in that condition check so basically you just say you know what just try to execute with whatever value and if error happens then i still got it covered and an obvious difference between this if else is that here nothing actually crashes the program the program will still work is just a nonsense value with zero days right and as you see here we have specified an error type but with try except what can also do is you can basically say you know what i want to cover any type of air i don’t care if it’s value air or some other type of air let me handle any type of air in this case you can basically just leave it without a specific type you get a warning though that it’s too general however this would work and you will be covering all the air cases with it but we can go back to our value error and know that in many programming languages this is actually called a try catch so accept is actually pretty specific for python i personally think try catch makes more sense because you are catching any error that may happen right here and then basically handling it in the catch block so if you happen to hear or see try catch in other programming languages note that this is the same thing as try except in python one thing that we’re missing because we converted that if statement into try except is now we need to validate the negative numbers again because negative numbers will not cause an error in our application so they’re not covered by this except block here so let’s add back our previous else block and again if neither of these are true it means automatically would mean that it is a negative number so let’s print that message for a user enter negative number no conversion for you so now we got all the cases covered again so let’s try that out -10 and there you go now there is one minor problem with our application and that is we can only use it once so basically whenever we type in a value it either calculates it or gives us a message that we provided an invalid value then the program basically exits so if we want to do a calculation for another value then we have to restart the application provided value and then do the same so that’s not very convenient if we want to use that program to basically calculate a number of hours for many different values so basically we want to keep fitting it some different values for calculation because we don’t want to restart the application over and over again so how can we actually make the program continue after it’s calculated the first value so we want the program to basically just keep running and accepting our values so how do we do that and we can implement the logic using something called while loop concept of loops in programming is basically you do the same thing so the same logic gets executed multiple times in a loop and how many times that logic gets executed is basically defined in the condition of that loop and the condition could be it should run 10 times or condition could also be it should run until some specific event happens in the application and conditions you already know from if else statement conditions are basically logic that gives you either true or false so condition is checking some logic and then giving you a result which is either true or false so now the question is how many times do we want this application to run in our case let’s say we want to run indefinitely right until we actually stop it from here until we kill the program so it means the condition for that should always be true and for our application we’re going to use a while loop which is one type of a loop and very simple syntax while and while just like if actually takes a condition this is going to be the condition for the loop so basically we want to tell the while loop how many times it should run the logic coming after it and again you know our familiar indentation these two lines should execute in a loop over and over again with some condition right here so how many times do we want the program to execute in our specific case well we want the program to run indefinitely until we actually stop it from here right from our editor so that means that condition of the loop that decides whether the next lines should get executed or not in our case should always be true because if it’s false then the loop will stop right no execution anymore so how can we make sure it’s always true we just write true right here and you remember i told you that true and false in programming languages have their own data types well they are also reserved words even though this is just text representation basically you see the highlighting here just like for these other words because python knows this is a boolean value of true and note that again specifically for python we actually write true with capital t unlike in other programming languages so this will basically be just a string so python doesn’t know what to do with it but it recognizes true width capital t so we’re telling our loop our while loop the condition is always true so basically run these two lines indefinitely because the condition will never change it’s always going to be true and the syntax is probably already familiar to you we have the keyword just like if or try we can actually compare the syntax to the if statement so we have the while keyword here then we have the condition so this is the same type of condition as this one right here it’s just that with us is basically fixed true value here it could be true or it could be false based on the condition and then we have the colon and then we have the indentation for the next lines so all of these belong to the while loop so that’s basically it we can now execute the application and see that our program runs indefinitely so this is the first one let’s say we enter 10 awesome we have a result and then we have again the next execution where it’s asking for our input again and we can do -10 now it’s telling us we provide a negative value but we can enter the value again let’s enter some invalid value that should be handled by this value error block execute it’s not a valid number and application basically continues so again as you see if you have an application that should continue running and basically get user input over and over again you don’t want that application to be crashed at some point by some bad input you want to catch and handle every type of input so that your application continues to run and if we want to stop it we can basically just shut it off here and process finished now we can do one optimization in our program and this would be to allow users themselves to stop the application using some specific input value so for example when they type in exit for example the application should stop only for that specific word so it shouldn’t run anymore so how can we do that so basically instead of having a condition that is always true we want a condition that says if the user did not input word exit then continue running the program if user entered exit then basically just stop it right so we need to change our condition right here so here we want user input is not exit right so user input is not exit now we didn’t learn how to check for not equals something right we have check for equality so we check whether input number equals zero or if it’s greater than or smaller than however we didn’t learn how to check for not equals not equals in programming and this is not specific for python is expressed like this so instead of two equation signs we have an exclamation mark and equals and if we want to compare it to a string obviously we type that string in our case it’s exit so basically this condition tells our while loop while user input is not exit continue running the program so while this is true basically just keep moving on but if user enters exit this will not be true anymore it will be false so loop will basically break and application will end now you see that we have a warning on this user input that we’re using here and if i hover over it you see a message that says name user input can be undefined so it’s not always undefined but it can be and here i want to mention again that pycharm because it’s an intelligent editor can give you actually this warning when otherwise in a simple or normal code editor you probably wouldn’t get such a warning so again it helps you in avoiding some of the mistakes that you might accidentally make when writing code so basically it detects the errors or possible errors for you and tells you to fix it so again this kind of intelligent warnings and error messages can be a lot of help when programming an application and now let’s fix that warning so what’s that all about the problem is on the very very first run of this while loop user input variable itself will not exist why because we’re creating that user input variable on this line first so our application will basically complain because when our while loop runs for the first time it will not be able to find user input variable let’s actually try that and as you see user input is not defined so we need to create that user input variable before the first execution of the loop so right here we’re going to create user input so we’re going to create this user input variable before the while loops first run and it doesn’t really matter what the value of that user input variable will be because what matters is the variable exists so the value is basically just empty and as long as it’s not exit the loop will start running and our application will get executed so again to go through the flow of this we’re creating a user input variable then we’re making sure it’s not exit if it’s not this line will get executed so we get the input from the user that’s going to be our first input and then we call validate and execute function that basically does all the checks and execution so that’s going to be the first run of that loop on the second run of the loop the condition will get re-evaluated so now the user input is what the user provided so again python will check is the user input exit no cool let’s execute the program again user will have to enter another value and then that value will get re-evaluated so note that after each time that this block of code has run and executed every single value that user will give as an input will be evaluated over and over again in that condition and while user input is something else then exit it will run the program if it is exit then the loop will break so let’s actually test that so this is our first message and our first input let’s do 10 it got calculated let’s do minus again calculate it and we can do that over and over and over again and now let’s actually enter exit and let’s see what happens and as you see a process finished with exit code so our application actually stopped because this condition was not true anymore it was false because we entered exit so that’s how we can allow users to finish the application and two takeaways here one is a conditional in a loop and the second one is a negative equals check for values great so now we have our application that basically allows inputs multiple times and can be terminated with exit input now what if i wanted to calculate number of hours for several days but i didn’t want to basically just pass it on one after another because that’s just too much effort for me so let’s say i wanted to give it 10 different values but i don’t want to type it in 10 times right i want that application to basically do the whole calculation for all those 10 values but i just want to enter that list once instead of entering each value separately so in this part we’re going to learn another data type in python called list so till now we have learned several data types like strings for example as well as integers and float numbers and boolean true or false and list is just another data type and the syntax for list is using square brackets and inside the square brackets we have a list of elements and those elements can again be either strings numbers or boolean values in our case we want to provide our application with a list of number of days right so we’re going to have a list of integers like this and you can have as many values inside the list as you want and these are going to be comma separated and the syntax will look like this but again as i said you can have a list of strings list of booleans etc so as i mentioned we want to let user basically provide inputs as a list instead of those individual values one at a time so i’m going to copy this let’s clean this up and let’s actually see what happens if i just input that list as a value right here and enter you see program doesn’t recognize that as a valid number obviously because we have the check and causes a value error that’s why we get your input is not a valid number don’t ruin my program message right here so we want to change that and make our program actually accept that as a valid input so how do we actually implement it and let’s go through this logic theoretically first before we start implementing it what we need here is that we want to read this list and we want to do validation and execution for each value one at a time so that means that validate and execute function needs to be called for each value in that list right so basically this function for all this logic needs to be executed for each element now how do we get the individual elements of the list so you remember the definition of a loop loop is basically executing same function with the same logic multiple times and the number of times basically depends on the condition right here we have a condition for while loop and the condition for executing the same logic for each of those elements is going to be the number of elements in that list right so we want to execute the logic as many times as we have elements in the list and for that we have another type of loop called for loop and basically we want to execute validate and execute function using a for loop the syntax for for loop is a little bit different first of all we have four keyword just like for while then we have the element is a variable so we can call that number of days so this variable basically represents each of those elements in the list and then we have in which is again a keyword of python so for in basically puts together the for loop logic in python so python knows what we are trying to execute and finally we need the list that we are executing this loop on and our list is our user input and that’s our for loop however again you remember the indentation the logic that for loop executes needs to be indented so it should belong to for loop so now we can read that for loop statement as follows for each element which we call we decide to call number of days in a list called user input we want to execute this logic exactly what i said before so for each element in this user input list we want to execute validate and execute function we don’t have a condition written here like we did in while loop or if statement so the condition is basically implicit right the condition says however many elements there are in this list that many times that function or that block of code here will get executed so if i provide five elements you will be executed five times if i provide 10 elements it will be executed 10 times and that’s exactly what we want however there are still a couple of things we need to do for this application to work properly first of all validate and execute function still uses user input right here so instead we want it to use the individual values of the user input because now it’s going to be a list and not a number so this element we can actually call it num of days element this value should be used here instead right so we’re going to use that element instead of the whole user input list and paste it here so that fixes the first problem and the second one is as you know user input is always a string so even if we provide a list of these it is still going to be considered as a string so we need something similar to this right here so the list of numbers that are provided as input needs to be converted in at least in python and we can actually do that in a convenient way using user input dot split and split is a function that will take user input as a parameter and will give us a list data type so split function basically will return a list of all those input values and again note the syntax of executing the split function we’re not just calling a split function like this with user input as parameter instead we are basically calling it on user input and i’m going to explain more about this type of functions in python later but for now let’s actually execute this application and see what happens so first of all how am i going to provide a list to this application so that userinput.split can actually convert it into a proper list in python and the way i should provide the values are list of values with spaces between them so basically like that so why spaces how come it’s not a comma or something else the reason is because split function by default splits that provided list on spaces and then creates a list value out of them so that’s the default behavior of split however we can override that behavior and we can decide you know what we want the input to be a list of numbers that are comma separated instead of space separated so what we can do is right here we can do split on a comma so that’s what our split function here will do and now if i re-execute it and i can do commas now 40 55. so that’s going to be user input and split with comma should convert it into a list value in python so let’s execute it and as you see it worked fine we have a calculation for each of those values now let’s actually play around with this and let’s say we provide a list with some values and somewhere in between we decide to add a text and then maybe a float so let’s see what happens now and you see that for those two valid numbers the calculation was done properly and for the other two basically the validation kicked in and it says that these are invalid numbers however again our application ran without any problems and we can even provide another input so now let’s actually do 20 maybe a boolean even and a negative number execute and you see that for 20 the number of hours got calculated true is obviously not a valid number and minus 100 is a negative number so everything works perfect validations in place and we can provide a list here now and as a final optimization we can actually change this message here that says hey user enter number of days as a comma separated list and i will convert it to hours so now we can provide either just one value and it works fine or we can provide multiple values as a list and again if we want to see how that list actually looks like and check the type that it has in python let’s actually print it so first i’m gonna print type of user input called split and then i’m just gonna print that list itself so let’s execute and let’s provide some values and here you see this is the class list so basically the data type list and that’s how our list looks like so we have these square brackets here and each element inside as a string because we have the quotes here and later our application then transforms it or tries to transform it into an integer and you also see there are some additional spaces here because that’s how we entered the values so basically the split splits the values on comma so this space also becomes part of that element so to fix that leading space in each value we can basically just add a space here so it will split on comma and space and let’s test it out and there you go we have our values without the space before them so you saw an example of when we actually need to use list data types in this example we wanted to allow users to basically just input multiple values at once as a list but obviously this is just one of the use cases for a list and one of the specific examples because throughout the application you can create lists and you can use the elements of that list in another function so you can use it for multiple use cases and just to show you some basic syntax of how to create lists within your code inside your application so how to initiate it and then how to use that list i will show you the examples here so basically to create a list in your code you would use that syntax that i showed you earlier with square brackets and inside that you would have list of elements and this could be strings so it could be for example names of month let’s say like this and then we would have to assign it to a variable right again just like we did for strings or integers or other data types so we can call it my list and this will give us a list with three string values inside and once you have created a list you can then use it to read the values from the list right so basically to get the individual values elements out of that list so for example if we wanted to print out the first element of my list then we would access that using my list and then following syntax with again square brackets and then index number of the element which is starting from zero so this is the first element with index zero this is the element with index one index two and so on right so it could be confusing because it starts with zero not with one but that’s how the specific element of a list can be accessed right so if i wanted the march value here the third element then i would just type in index two and this is a syntax of getting elements from a list if i just want specific values and not each element one by one as we had in this example right so one way to use a list is to basically loop through it and get one element at a time and that’s why we don’t need to use index here because it gives us elements one after another or maybe we don’t want all the elements or to do something for each element we just want specific values from the list for different use cases in this case we can access them individually like this and in addition to accessing the values from a list or basically reading the values from release we can also add values to a list and we can do that by typing my list and then on the my list we’re going to do dot and use the append function right so append will basically take the next element or another value basically and add it to the list of elements already in the list right so let’s say we want to add the next month and now if i print my list we should actually see this here with april as a fourth element right so let’s execute and there you go so first we have march here printed out which is the third element right index two and then we have my list append that adds fourth month name into the list so after append this is how my list will look like and now again we can access the specific element for example if we wanted to access the newly edit element on index three so that’s going to be the fourth element and there you go we have the new element printed out and also an interesting note is what happens if we use an index here which is too high so basically pointing an element that doesn’t exist right so instead of three let’s say we have four here so this will point to the fifth element and since we only have four elements let’s actually see what’s gonna happen so i’m gonna execute this and there you go you see an error index error that says a list index out of range so every time you access or you try to access an element at an index that doesn’t exist you will get this list index out of range error and this is actually something that may happen pretty often when working with lists if you’re accessing the values like this so this is how you work with lists how you create them and access values in them as well as add some values however note that most of the time if you are using lists you’re going to be using them in a for loop because most of the time you would want to do something specific for each element in the list so this basically should give you an idea of syntax of lists and how to use them generally and also how to use them in combination with for loops here i want to take a few seconds to thank jetbrains the creators of the awesome pycharm and intellij editors for sponsoring this complete course besides all the great existing products they have they recently introduced space which is an all-in-one team collaboration platform covering software development project and team management and the great thing about space is that every single tool you would need in a company to collaborate and work together in a team is in one space so you have tools for chats blogs planning and creating tasks meetings but also software development tools like version control ci cd package repositories and much more so all these in one platform and in terms of productivity the great thing is you get all the notifications in one place like code review updates newly created issues new blog posts etc you get all of these in chats where you can react directly in place or add them to your to-do list automatically so i think the main value of space isn’t that it has all these tools but rather the fact that it integrates them in such an intelligent way that it improves the team communication and productivity overall now let’s go back to coding now at this point here i want to mention a pretty minor and simple detail but something that is also very important and useful in programming and that is comments so how do we write comments in python and why do we need or in which cases are comments actually useful one usage of comments is basically to give yourself some notes on your own code so basically if your code gets a little bit complicated and it’s not really clear what the logic or the function body is doing it could be because of bad programming but also because the function logic is just a little too complicated so you want to add some textual notes to that code so that you understand what’s going on there even when you look at that code days or maybe weeks after you wrote it so for example right here we may want to add some notes about what this part here is doing and comments in python are written with this character so for example i want to add a note here we want to do conversion only for positive integers and that’s basically my note that summarizes all that logic right here and it is not only useful for myself in case i forget what this complex logic actually does but also for your team members so if you’re working in a team and your code gets really complex and it’s difficult to keep an overview of different functions and variables and what all these things do you can basically add these comments as notes to your team members so they can also understand what you thought or what kind of logic actually you were thinking about when writing this code so comments is a way of communicating your thoughts and your logic on your code so that’s one use case for using comments and the second use case if you have a piece of code that you do not want to delete because it has some logic or it has some example that you want to keep as a reference but you don’t want that code to be executed so basically you can comment out code so that it still stays there but doesn’t get executed and the way to do that is just basically having this character before the line and also note the color of the comment in the editor is gray so it’s immediately visible that these are the comments and now these two lines will not get executed by the program they will be ignored but they are for your own reference in case you want to keep it there for example this could happen if you are unsure about the change and you want to delete that whole code from your application because you might actually need that eventually so you’re not sure about it so temporary comment the code before you permanently delete that so these are some of the use cases of comments now if you have multiple lines of code that you want to comment out or maybe hold text that you wrote as a note so for example you want to comment out all these four lines here obviously you don’t want to do this in front of every line so for multi-line comments you can actually use the following syntax which is three quotes at the beginning and at the end and again you see the highlighting is different here which basically is highlighting of a string however it is ignored by the program and it will not be executed as a best practice you shouldn’t have too many comments in your code because it will just add additional clutter and your code will look basically unclean so you should use them only when needed in this part i’m going to show you another data type in python called set so what is a set let’s start our application again and let’s say i provide here input values as a list let’s say 20 40 and 20 again so basically i have duplicate values in my list and when i execute it i see that the program got executed for each element and i have duplicate results because i passed in the same value twice now again users they can input any value they want either intentionally or accidentally this could be bad values or things that don’t make any sense so let’s say we want our program to behave in a way that if user provides the same values twice or three times we only want to calculate the number of hours for that value just once so basically for this input we want just those two lines and basically ignore the execution again for the same value and you probably already guessed that’s where set data type will help us so set is basically a list of elements but with unique values inside so list data type allows duplicate values the same value multiple times set does not allow duplicate values so how do we use set instead of a list and it’s actually very easy to convert an existing list into a set and we can do that using a function called set and basically the parameter of our set function will be the list so if this list here contains any duplicated values that will be basically just filtered out when we convert it into a set so that’s how it works and again for demonstration let’s actually print out how set value looks like so i’m going to print the list first so that we can compare then we’re gonna print out the set and let’s also print out the types and i don’t want to repeat this expression over and over again so what we can do even though this is just for demonstration we can actually extract it into a variable let’s say list of days like this and we can use it everywhere we need and this is a little bit cleaner because we don’t have to repeat the same expression over and over again and again let’s print out the type of list of days and then print out the type of a set of lists of days and again you see that nested function calls three times and this should give us some interesting value that we can compare lists and sets and just a small note here that whenever we have this nested function calls think of the execution from inside out so the first function that will get executed in this chain is actually the set right so it starts from the last function in that chain so set function will get executed and convert that list into a set then type function will get executed on that resulting set value and then print will get executed and print basically the result of the type so the order goes from innermost function to the outer functions so let’s save it and execute and now i’m going to again provide a list let’s say 10 and then 45 and 30 and 10 again and enter and first of all we see that 10 only got executed once and not twice and we can also see the first one is basically value of a list and you see at least here the second one is a set and you already notice the difference that list basically uses square brackets and set is represented using curly braces right and again it has value of 10 just once and again we have the data type of a list and a set so just to demonstrate that they are actually own separate data types and like we saw previously with lists we can also create sets as well as add an excess values from it so let’s see an example here for example if you want to create a set the syntax for that will look like this as we already saw again set can have strings or numbers or booleans as its elements let’s use the same example we use with lists so i’m gonna just basically type in names of the month here so let’s say we have again january february march and we’re going to assign that again to a variable so this will give us a set that we can create ourselves not just from the user input and now we can access the values the individual elements from the set and we can also add elements to the set however we cannot access the individual elements of the set like we did on lists right you remember on lists we use the syntax with square brackets and the index of the element in set we cannot actually do that instead we can only access the elements of a set in a loop so for example in a for loop we would write element in my set and then we can basically print that element so let’s execute and right here you see all the elements printed out and again as i mentioned with lists also previously most of the time when you’re working with lists or sets you’re gonna want to look through the elements because you probably would want to do some operation on individual elements or some of the elements right instead of just grabbing individual one or two values from that now how do we add elements to a set let’s see it as well we can add elements to my set using my set so the set itself the variable name and then if you do dot you see a bunch of built-in functions again set has its own built-in functions which are completely different from what list has and it has a function called ed and here we can basically add a new element again let’s do april and now we can print my set and execute and there you go so we have here individual elements that are printed out and we have the new list after we edit april now one thing you probably already noticed when working with the set like printing its elements or adding a new element it doesn’t work in the same sequence as with a list right so for list we basically had this january february march in this exact order and when we edit a new element basically it got added at the end right as a fourth element in set it’s not ordered it’s basically in a random order right so if i execute this again rerun you see the order changed here and here as well right and if i do it again there you go so this order and this order basically changes right so as you see working with sets is actually pretty different from working with lists so this means that set not having or not allowing duplicate values is basically just one of the differences between sets and lists and of course you’re probably wondering i can add elements i can access elements what about removing elements right from lists or sets and you can do that actually the same way for both sets and lists so for example if we want to remove an element from a set we can execute a built-in function called remove and remove basically takes a parameter which is the value itself so let’s say if we want to remove january from here then we’re going to pass the value to remove function and now if i print my set again after the remove gets executed and let’s run it and here you see the last print basically doesn’t have january inside and as i said it works the same for lists so let me demonstrate this as well so on my list which has its own set of built-in functions one of them is remove which in this case is called the same for both set and list and this remove built-in function also accepts the value of the element you want to remove and let’s print it again my list and execute there you go this is a set with the syntax with curly braces and this is a list which now doesn’t have january inside because we removed it and as you know lists can have duplicate values so if we have january again here so two times and we do remove january it will actually remove the first occurrence of that value so if i execute this you see the first one got removed and the last one or the second january value is still there so that’s how you work with sets basically and also how to remove elements from sets and lists so at this point i want to take time and review the functions that we have used from python itself so the functions that we ourselves didn’t actually write and the functions that python basically makes available for us to use are called built-in functions so till now we have used function print which basically just takes some input this could be a string this could be a variable this could be a number doesn’t really matter and basically just prints it in the output console right in the terminal we also saw input function that basically takes user input again we can provide a parameter which will be a message or leave it empty we also in the last example so an example of set function which basically takes a list and converts it into a set and another example is int again takes a string as a parameter and converts it into integer and all of these are built-in functions because python provides them to us so that we can use it in our code and in python there are a lot of very useful built-in functions for different purposes and as i mentioned most of these functions basically accept a parameter and then do something with that parameter that input that we provide that function and give us an output again print basically provides something here and gives us the output in the output window here in input we can provide some message that will again print an input here and the rest of them are giving value inside the code without displaying anything so in set we can provide a list and the same way a parameter here which is logical because the purpose of a function usually is to take some input like this as a parameter do something with that input and give us an output from that parameter and we have created our own functions that also take some input and give back some output like this and in addition to built-in functions that are called like this and our own functions we have also used third type of functions which is called directly on a value right and this is an example of that so basically directly on a value this could be a variable but also the string representation of that itself so if i had a string like that so basically directly on that value call a function like this and these are also built-in functions because python makes them available to us other than the syntax there is one major difference between these type of functions that are called directly like that and the functions that are called on the value itself and the main difference is that each data type has its own set of functions that can be executed like this so again let’s take example of a string and if i do dot here you see the ide pycharm basically gives me a list of all the functions again built-in functions in python but functions that i can execute on a string value and again you see split is digit this is the one that we used in one of our previous examples that basically checks if that string is a representation of a digit or just a regular string and as you see lots of different functions so all of these are provided by python to do different stuff like turn the string literal to uppercase or replace a letter for example in that string and so on but the main point here is that those functions are only for string but as i said each data type has its own list of functions that can be called on that data type so for a demonstration let’s take a list and if i do dot here again you see a list of functions that i can execute specifically on list values and there are lots of things that you can do with lists like add elements to it remove elements from it sort the list copy and so on so that’s basically a major difference between these type of functions and functions that can be executed on specific data type values but the concept is the same here you also have a function that gets a parameter an input and gives you an output and the parameter for this type of functions is actually the value that we are calling that function on so this string here 2 3 is going to be parameter of the split and in addition to that we can also provide additional parameters for example for split you saw here that we were able to add a comma space to basically tell the split function on which character to split that text so that was function comparisons in a nutshell in this part we’re going to learn a new data type in python called a dictionary and we’re going to do that by modifying our application and modifying how users can actually input the values now our program currently takes the number of days and turns it into a number of hours what if we wanted to make our program a little bit more advanced a little fancier and basically allow users to also decide what units it should be converted to so user gives us the number of days and tells us whether to convert it into hours or minutes so instead of the whole list now we’re going to get just number of days and the conversion units and this change may be a little bit complex in terms of syntax so i will try to explain everything step by step so the first thing we need to do is adjust how we get input from the user so now we want the user to be able to give us the number of days and units in one input so first of all i’m going to adjust the text here enter a number of days and conversion unit now there are a lot of different ways we can allow a user to do that but what we want to do is something like this as an input so basically number of days colon and minutes or number of days and hours again this is our own decision we decide how the user input should look like but this should be a nice way of providing both of those values basically colon separated so instead of a list we’re going to have a single input with two values that are separated by a colon so on the next line i’m going to change this split here into a column and this will give us user input this whole value split into two values as a list this is going to be day and days and unit so least with these two values and let’s actually get rid of this for loop because we’re not iterating through a list of numbers anymore and to begin with let’s just print out the output or the result of days and unit variable so i’m gonna refresh and let’s do two hours and enter and this is what we get so basically splitting this string on column will give us a list with elements 20 and hours and note that 20 is still a string right because that’s how we get the input and now from those two values we’re going to create a value of a data type called dictionary so in python we have another data type called the dictionary which basically looks like this so you have curly braces just like we had for a set and inside we have key value pairs so we don’t have just single elements like this but rather we have key value pairs so key in our case is days and the value of that key in our case would be 20. and then comma separated another value would be unit and a string hours so basically this is the syntax of a dictionary and obviously the difference between a list and a dictionary is that we have descriptions for each of our values represented as key value pairs so we want to create this construct right here from those two values and since this is a data type we can create a value and assign it to a variable of that data type so let’s call it days and unit dictionary equals and obviously we don’t want those values to be hard coded here we want to get it from the list now how do we access an element of a list how do we grab the first value which is 20 out of that list and to do that there is a syntax to access the elements in the list the list name and then you have square brackets and index of the element which if you remember you already learned in the section of lists so again days of unit list is this one right here and with index 0 we are accessing the first element index 1 is the second element and so on and index is basically just location this is location 0 location 1 and so on so this will give us the first value and obviously the second value is going to be with the same syntax with index one and let’s actually print that one out as well so that we see the results restart the application let’s do 20 hours so again this is our list 20 hours as two separate values and this is a dictionary that we created using those two values so we have key value pairs basically and the same way for minutes we would end up with a dictionary that looks like this so now we have these two pieces of information in one variable and now we can give that variable to our function so that it does the validation first of all of the number and calculation based on the units so on the next line we’re going to call our validate and execute function and as you see we have this red line here because something is wrong first of all we don’t have this variable called num of days element anymore because we deleted the for loop instead we have days and unit dictionary and here we are validating the integer value of the input number and the same way we need to validate this input number here as well so now the question is how do we access a specific value in this case the value of days here in a dictionary because we have to validate this value as well because i might as well have entered text instead of this number so the way to access values inside a dictionary is again using the square brackets just like we did for list but instead of an index index 0 or index 1 we don’t need to use an index because we actually have a key so instead of index we’re going to use the key like days or unit and this will give us value of 40 which will then be converted into an integer and then validated right here so again i’m gonna copy this for comparison so to access an element of a list let’s say my list here and let’s do 20 30 doesn’t matter in order to access the elements of that list we can do that using an index so this will basically print number 30. again if we had other elements here we can do index 2 so that will print out 100 and let’s actually check that and remember to comment out a multi-line code we can use three quotes at the beginning and at the end let’s refresh and there you go 100 was printed let’s do the same with the dictionary so we have a dictionary days like this and to access an element inside that dictionary we use the square brackets and instead of the index like here on the list we use the key itself and again i’m going to print this and there you go you see value 20 and i can also access unit value and if i execute it i see hours and so on and i can add any number of key value pairs in my dictionary as i want so for example i can add a message here all good and i can access that message like this so this is how you create a dictionary and that’s how you access the values in a list or in a dictionary so let’s clean this up comment in our code again like this and get back to our code so basically again this is how we access the number of days in our dictionary and in our days to units function we need both of those values and we can pass in those values separately so we already have a user input number from the dictionary and the second value would be the unit from the dictionary however we have to add that second parameter to our function so let’s do that unit let’s call it conversion unit so now we are passing both of these values to our function so we have the user input number here which is already converted into an integer and the second one which is the conversion unit and now we can finish the logic in this function here right now we are using this hard-coded calculation to units which is 24 and number of units which is hard-coded hours so first of all i’m going to remove those two we don’t need them anymore because we get those values from the user and now we have to substitute those two so here we’re going to check if the conversion unit is hours equals hours then we’re going to return calculation with hours it’s going to be 24 and conversion unit here we can also hard code hours here because we know it’s hours else if so if the conversion unit is minutes then we can return calculation for minutes and a text like this and it could also be that the conversion unit that was provided is none of those or maybe some invalid text and in this case we’re gonna add final validation so if it’s neither hours nor minutes then we’re just gonna say you know what unsupported unit so basically we don’t do conversions other than those two so we just tell the user that’s an unsupported unit and now if we execute our program and enter value there you go we have our output and same way if we do 90 days to hours we have our calculation in hours so that’s how dictionaries work we can do one final thing here and as usual print out the type of our dictionary and there you go you see class of type dictionary here which is another data type and at this point we can actually summarize all the data types that we have learned so far so let’s give us some space here so first one was string so basically a message or some output like this that’s our string then we have integers example of that we saw already days then we have float numbers which for example can be used for price or weight of a product etc we also have learned boolean data types when we check some kind of condition whether if it’s true or not so for example is it a valid number or is the user input exit we also learned a data type of lists so for example usage list of days like this including duplicate values and list data type can be used for strings as well not only for numbers so for example we can have list of month like january doesn’t really matter we also learned a data type called set and set basically is very similar to list but it doesn’t allow duplicate values and its syntax is with curly braces so the same way we can have numbers or strings or booleans or any other data types inside a set and the last one that we learned was a dictionary and let’s take our own example day in unit and dictionary is basically a collection of key value pairs and the syntax is written like this so why do we need all these different data types well depending on the use case or what exactly you are trying to achieve in the program you’re gonna need a different data type to achieve exactly that so each data type has its own specific purpose and throughout these days to units calculator i try to demonstrate the purpose of each data type and when we need to use them so these are all the data types that we learned these are also most of the data types available in python and the main ones that you’re going to be working with so this should give you a good foundational knowledge about data types in python and also note that most of these data types you will also encounter in any other programming languages because as i said these are the core data types and most of the programming languages actually support these data types as well till now we have been writing all our code in one single file so basically we have a project with just one python file and we’re writing all the logic inside that file however you can imagine that if you’re writing a little bit more complex applications that have much more complex logic so they end up having lots of functions obviously you’re gonna end up with a python file that has hundreds of lines of code maybe thousands of lines of code and it’s not very practical to manage all this logic and all this code in just one file so instead you need to structure your code and divide your logic between multiple different python files and you do that with modules to give an example imagine a web application that has basically many features like facebook for example obviously you can put all the facebook logic in one single python file right you will have a structure of facebook project with subfolders in your project which all contain multiple python files so you would have maybe packages for each feature and each such feature has a lot of functionalities so they will be all grouped then again in multiple python files right so you would end up with a project with a hierarchy of folders and lots of lots of python files inside now the question is if i have multiple python files in my project how do i connect them together so for example if i have another file here and let’s call it helper dot py and if i have some logic here basically functions defined here how do i use them or how do i reference them in another file and the way it works in python is using the concept called modules so a module is basically a python file that contains functions or variables that you can use in another python file so basically any python file that you have in your project both of these in this case are modules and you can reference one module from another so basically the idea is that you can structure your application your program using modules so you can make your project modular so in this part we’re going to create our own module in helper file and we’re going to reference that in main dot python and let’s say in main.python i only want the code that basically starts the program right all the functions all the logic i kind of want it hidden away and grouped together in a separate file so what we’re going to do is copy this entire thing so both of these functions basically and paste it in here so now you already see a couple of red lines here because now the reference is obviously broken right so main.python obviously doesn’t know anything about validate and execute function right it says unresolved reference and the same way face to unit dictionary is unresolved for helper because it doesn’t know anything about main.python and the variables defined right here so the first thing we need to do is we need to tell main note python file where to find this validate and execute function right we have defined it in helper python so that’s what we need to define how we do that is using something called an import statement so we basically import this whole helper.pi module inside main.python and we do that very simply using import helper right helper is the name of the file and therefore name of the module and right now it’s grey because we’re not using it and the way to use it is helper dot and the function name and you see the red line disappeared so again what we did is we told main.python there is a helper module in this project and please import this whole module and all the functions that this module has and make it available in main.pi and then once we have that helper module we can reference any functions if we had any variables using module name dot function so this has to be the name and if i hover over it you see that pycharm actually displays the whole path to that helper.pi file and now note that here we still have redline because this is a variable which is defined in main dot pi but a helper module doesn’t know anything about it and that’s an important distinction here because we imported helper module inside main so helper modules functions are available here but not the other way so in order to make this dictionary available invalidate and execute function we would need to pass it in as a variable like this and this will work now now note that in main.python we actually only need this validate and execute function we don’t need the days to units function because this function is only used by validate and execute function so that means that we don’t need to import the whole entire module inside main.pi we actually only need the validated execute function and this is a small example but if you had a module with 20 30 functions and you just needed one of them you wouldn’t need to import the whole module just for that one function so what you could do is you can pick and choose which specific functions you want to make available inside another file or another module and you can do that very easily using the following syntax we say from helper that’s the module again import and the name of the function like this and now because we are accessing and importing that specific function we don’t need to use module name anymore we have that function available directly so we can delete the module reference here and we have that function available like this so again instead of having entire helper module with all of its functions and other stuff we only have one specific function available here so that means we wouldn’t be able to use these two units for example now we saw an example of a module that has just functions right however module can have many other stuff for example variables and you can make those variables also available for another program and that’s an example here i’m going to create a variable called user input message and this is our user input message and we can actually put it into a variable instead of having it defined like that so i’m going to copy it and paste it here so now we have the user input in a variable in another file again how do we access it in main dot pi in this statement at the top we can actually import several things from a module right now we are importing a function we can also import our variable and we can do that also very easily like this and we can use that user input message here so basically if you have again 20 functions and variables from a module and you just need maybe five of them you can import them individually like this just basically just list the names of functions and variables what you can also do is import all this is what this asterisk sign represents so we’re basically importing everything from the helper module again this is kind of a waste if you just need a couple of functions and variables from that module and not the entire thing however with this syntax you can import everything and now you may be wondering what is a difference between importing everything from the module and importing the whole module because in both cases you have everything in the module available the difference is in the syntax because note that if we use this from import statement you don’t need to use name of the module every time you’re accessing something defined in that module right so we don’t need to do helper dot function name or helper dot variable name whereas if we imported the module like this you see we have red lines because we would need to do helper dot or module name dot whenever we use something from the module now this could be a matter of taste so basically which one you want to use i personally think that this is the most efficient and also cleaner way of using specific functions variables etc defined in a module and as a side note the things that are defined in a module that you can use basically in another file are called definitions so all these those three elements here are definitions of a module and you can use any of those definitions in a file where you import that module what you can also do when importing a module is you can rename that module basically to whatever you want so if the name of the module is too long or you just want to use a different name you can do as and then basically write a name whatever you want like h for example and then obviously you need to use that new name everywhere you access functions or variables of that module so basically how you import a module and whether you rename it is a matter of taste basically how you want to do that in your code however i think that importing specific elements from a module like this is most efficient and also cleanest way to do that so we saw how to create our own module and use it in another file so basically if you had hundred python files here with each one of them having their own functions and variables you can cross reference them from each other using the import statement very easily now in addition to creating your own modules we can actually use modules that python itself already includes so just like we used some functions that python gives us out of the box like inputs or ins so basically all of those the same way python also gives us modules for different scenarios so that we don’t have to write this logic ourselves and there are a lot of useful modules that python actually includes for example math module for mathematical operations its own module for working with dates or date times module for working with specific files and so on so basically for many different use cases python already gives you ready modules and these modules will then contain multiple functions and variables for that specific use case again if we take an example of a date so if you have an application that works with dates and times you have this module from a python that gives you a bunch of useful functions for working with dates and again this means you don’t have to write this logic yourself but rather use the existing one so to give you some examples of modules that python provides us with for example if you want to work with operating system there is an os module so we can print out we can get the name of the os for example and i’m going to comment all this out and run and you see the name of the os another useful module python offers is logging so if you want to use logging in your application the logging module gives you different functions to log an error message or warning etc as well as basically just configure how the login will look like again to see an example again it may look a little bit complex here but essentially just using the name of the module and then functions that it gives you obviously you need to know the functions and you need to know how to use them and you can get that information from documentation or if you’re using pycharm it actually gives you all the information about these functions and the module if you just hover on it so you don’t even need to google or check out the documentation and basically we’re creating a logger and we’re logging an error message so if i execute this now and here you see the output of the logger error happened in the app and logging in application is actually a very important feature so that’s why logging module is available by default in python any use case in our application would be right here if an error happened for example instead of using a print basically just log and error so these were just some basic examples but as i said python comes with lots of very useful modules that you can use in your applications for different use cases and that of course makes your work easier because you can just use the logic instead of having to write it yourself in the modules that are part of python so that you can import them like this directly are called built-in modules we learned about built-in functions so these are the functions that python makes available to us directly and there are built-in modules that we get from python and by the way if you’re wondering where this module actually comes from so where is the physical location on our machine or where this module files actually leave if you’re using pycharm you can actually hover over it and hold down a control key or if you’re a mac command key and click inside you see the file opens up which is the module the logging module since i said module is basically just a python file that has multiple functions variables etc available and you see right here on this top line the whole path for that python file so that’s the location of that module file locally on my computer and inside this python file basically you again have python code and if we look for get logger function here like this right here you will find the definition of that function right so somebody implemented this function and called it get logger and this is basically the logic all the things that get executed behind the scenes and you as a user of python basically can use the name of the function and write your own programs with it and let’s also look for error and there you go we have error function as well right here and obviously this is a more complex code here than what we write but just to give you an idea that this is actually a file on your machine that comes with the python version that you install locally and all the functions are defined already there by python developers and you can just use them like this without worrying about how the logic is actually implemented and another interesting thing is if i click here in this python 3.9 like this logging is basically one module that we used and here you will see the list of the complete list of all the built-in modules that you get from python so some of them are folders like logging for example email and bunch of other stuff and the operating system module for example that we used is a python file then you can find right here so these are the built-in modules so now that we know what built-in modules are and how to use them let’s actually see a realistic example and also write a little more interesting application using built-in module so what i’m going to do is in my python project i’m going to create a new file and i’m going to call this time to deadline dot pi y and we’re going to write an application that basically accepts a user input of a goal and a date like a deadline date and then we’re going to print out back to the user how much time it is remaining till that deadline and that deadline will be a date right some date in the future so that means that we’re going to be working with dates and in order to work with dates we are going to need python’s built-in module that allows us to call functions and do some processing and stuff on date values and that module is called date time so import date time so let’s have that import statement right there and we’re going to use it in our program so the first thing we want to do is let the user give us an input about their goal and a date or deadline for that goal so let’s do that first we already know how to ask for user input with a message so we’re gonna say enter your goal with a deadline separated by colon and we also know this already basically what we want to do is user to be able to enter their goal like learn python column and a date and let’s say again this is totally up to us to decide we’re the ones basically setting the rules here so let’s say we want the date to be entered in following format day month and a full year like this so that’s the format that we’re looking for and this is how user should input the value otherwise with a different format it’s not going to work so we’re going to save that input value into a variable let’s call it user input so we have the user input let’s do the split again on a colon remember we have this whole thing as a string as one string so we want to split it into two parts so we have the goal here and the deadline and this will give us a list with those two values and let’s call it input list and now from that list we can actually extract or get those individual values using a list syntax so accessing the elements from a list which is what we learned already using an index right so we have input list index 0 which is going to give us learn python and let’s save it as a goal variable and let’s create another variable which is going to be date let’s call it deadline and this will be the second value in our list now let’s actually print this out print this whole list out and now note that we are actually in a different file we’re not in the main.pi anymore and we don’t want to execute main python file instead we want to execute this one right here we basically just want to ignore everything else in this project so how do i go from main to this file execution very easy in this editor just to right click and you see here run time till deadline and i’m going to execute this everything else is ignored in the project we are basically just working on this one right here so enter your goal with the deadline separated by colon let’s do that i’m going to do pi learn python colon and then let’s enter some date and enter and this is the output so we basically split that into two values and put it in a list right here and very important to note here that both of these elements in this list are strings because again user input is always interpreted as strings so this was a string and it was split into two strings which are learn python and this date here however we don’t want date or deadline as a string we want deadline as a date and exactly for that functionality we need this date time module because we don’t want to implement it ourselves we want python to give us a ready function from a module that will basically just let us convert this string into a date value and converting string to date is just one example usage of date time module but you can use this module to work with dates generally like creating new dates formatting the dates updating the value etc and we’re gonna see some of those examples in this section now if you’re learning this type of thing alone you don’t have me basically teaching you and giving you an example the way you would do that is you would basically research and maybe google how this is done in python and you would basically see some examples of using this date time and what the name of this function is and how to use that as well as each module has its own documentation page where you can look up the syntax and usage examples because obviously you’re not going to know how to do that by yourself so the way we convert a string into a date using this date time module is on this datetime module if i type in dot i will see a list of all the definitions that daytime module gives me right so i have date daytime time etc the one that we need is date time because the function that we need for conversion is inside that definition and don’t be confused here because we have date time twice here the first one is a module and the second one is a definition in that module and we can actually check that as well so if i jump into this date time module and inside that if i look for date time again so right here you see this date time definition and on that daytime definition we have now functions that we can use and as you see this is not a function or variable it says class here which is another concept in programming we’re gonna see later so just for now think about this as a container of functions and variables inside that module and that’s why we have to access it like this and then on that daytime definition this class we now have functions that we can use to do the conversion so the function we need is called str so string p time and this function will take a string representation of a date and we’ll convert it into a date format so our string representation is deadline and we need to pass in the second parameter because remember i said we basically decided that the date should be entered like this with points and a full year here and as you know there are lots of different formats and types for dates right depending on a country or a language or even within that language we basically have multiple different formats right we have formats like this or we could also have a shorter version of the ear etc so we need to define here the format that we want python or this method here to use when converting this string into a date again because there are so many different formats available so what we have here is a day then we have a dot then we have a month again a dot and then we have an ear so this is kind of a main structure of a format however formats for dates have their own specific syntax and this is actually for all programming languages so what we need to do is put this percentage sign in front of every letter so again we have day month year and there is one more thing about this format this format right here matches this date however we want the full date not just the last two and the format for that would be a capital y again this is something that you would look up in the documentation of the module instead of knowing it by heart but just know that this type of formats are used when working with dates and this is not specific to python you will actually see something very similar in all the other different programming languages and that will do exactly what we want it will take this date here and give us a proper date format from it let’s actually test this so i’m going to print this first and i’m also going to print a type a data type of that value so let’s execute i’m actually going to copy that so i don’t have to retype it over and over again and enter and here you see we printed first of all the date not a string and now this looks like a proper date and not a string anymore note the change in the format plus we have these zeros here which represent hours minutes and seconds we didn’t set any of those so these are all zero and we have the date time type again note date time for a module name and date time of the class name so this is the type of our converted date and the reason why we needed to convert that string into a date is because we want to calculate how many days or how many hours are remaining until the deadline from now starting from today and to do that calculation we need to have date type because we can’t do that on a string great so now we have our deadline represented as a date so let’s actually assign this to a variable it’s a deadline date like this and remove this and now we need to do a calculation how many days from now till the deadline we already have the deadline we need now again now is or today is also a date and since we have this module date time we can also assume that this module will give us some function to tell us the date of today and if i do date time again daytime class and today you see that we have this function available and this will basically give us the date of today so depending obviously when you execute this program it will give you always the current date so let’s print it today for me it’s 7th of february so if i execute it now i’m going to enter this and today is 7th of february for me so if i execute this let’s actually comment this out here i have the date for today which is 7th of february plus the exact time it is now but we don’t care about the hours and minutes and seconds we just care about the day so that means we already have deadline and we have today let’s also add it to a variable like this and now we can actually do the calculation calculation is super easy we just say deadline date minus today date and this will actually give us the difference between or time difference between today and the deadline date in the future again let’s actually try this out and you see that so this is 12th of august for me today is 7th of february so the program calculated that there are 185 days until the time plus how many hours minutes seconds and milliseconds so that was a pretty easy calculation now what we want to do is tell the user some kind of message and we want the message to be dear user the time remaining until the deadline for your goal whatever the goal was is this so let’s actually put that text and message together and bring it back to the user so first i’m going to save it into a variable let’s call it time till and the message dear user time remaining for your goal and here we want to print what the goal actually is and you remember how we format a string when we want to use a variable we put an f here and in curly braces now we can use variables or numbers or some other expressions which are not string so first of all we’re printing back the goal so time remaining for your goal whatever goal they entered is time till and let’s execute our program and let’s give it some other value like this and enter and here we have our message dear user time remaining for your goal learn python is 132 days and this many hours minutes etc now let’s say we don’t care about this whole thing here we just want to know how many days are remaining so how do we get rid of this part here again very easy and the time till if i do dot here i get a list of suggestions for functions or variables that i have available and one of them is days as you see here so if i click here and save and i’m going to reuse these inputs because i don’t want to type and as you see we got rid of this whole thing here and we just have days and let’s actually write days and there you go we have a cleaner output now for our user and finally what if the deadline was just a couple of days in the future and the user wanted to know how many hours are remaining till that deadline we can do that by getting rid of these days and again type in dot and we have something called total seconds here which gives us the time different in total seconds and now we can reverse engineer and calculate the number of hours from this total seconds which is pretty easy like this calculate minutes and then calculate hours and i’m gonna execute this again and here you see the number of hours with a decimal precision so we have 4450 hours point some fraction number here again we want to get rid of this extra stuff and as you see from the syntax it is actually a float number with a dot here so what we could do is basically convert this whole thing this float number into an integer so convert this whole thing into an integer using int function and we need this whole calculation here inside the int function and let’s execute it again learn python and let’s choose a date which is near and there you go we have a whole number 57 again cleaner output and as a code optimization we could take this whole thing out into a variable and call it hours till to make our code a little bit cleaner so now we have the whole program that takes user input and basically prints back to them how many hours are remaining till the deadline for their goal and for this program we used a date time module a built-in date time module from python and we also learned a new data type which is date time and as we learned from the module section we can actually optimize the import of the module because obviously we’re just using the date time definition and nothing else from that module so what we could do is from date time module import date time definition which is a class in this case so now you don’t need to use the module name so let’s get rid of those and this could make the code cleaner as well as make the import more efficient because we’re not importing the whole module even though we just need one definition from there when you install python it comes with a set of modules that are built in into python however there are many more modules for other different use cases like web development or data science and machine learning etc that are not part of that installation and these are basically external modules not built-in modules that you have to install as you need and this makes sense because the built-in modules are the ones that most of python programs will probably need and depending on what specifically you are doing with your program whether you are developing a web application or creating some machine learning program you can then add and install them as you need and there are hundreds of such external modules for python out there and obviously it wouldn’t be practical to have them all on your laptop when you’re just gonna use maybe a handful of them right now if i need to install an additional module for example django for web development where do i find these modules and how do i install them python modules actually live in a module repository where you can find them and that module repository is called pipey so if i look for pipey right here you see the python package index if i click inside you can search for any module that you want to add or install additionally for your application and here you see this word package everywhere instead of a module so what is a package or what is the difference between package and a module to give you a simple comparison module is basically a python file like this one right here that has a name of that file right so we have an ssl module or the one that we used earlier we have this os module right so module is one python file that contains all these functions and variables that you can use package is a collection of modules so if we scroll up and logging is actually one our example so these are actually packages and again let’s go to logging so package basically contains multiple python files and use it in the same way you basically import the functions and definitions from the module and as you see clearly the difference is that package is more structured so for example the code is not available in just one single python file but it’s divided like this in our case we have two python files and package always has this init python file and this file basically differentiates a normal folder like we have right here with bunch of python files from an actual package with python files so that’s the difference between modules and packages and many external modules basically that we want to use in our projects are actually packages so basically package is a good way to define some hierarchy and structure for your modules and kind of group them together so that’s why you see package here as a name instead of module so now that we know the difference let’s actually search for a package for our project so for example if i type here django you see django packages that we can use from here we also have numpy and so on however in programming when working with and using these external packages a typical example would be where you need to implement some logic for example you want to write a program that basically talks to aws maybe and you don’t know exactly the name of that package but you know what you’re looking for so in this case instead of the exact name you would actually type in here in the search projects box a description of what you’re looking for so let’s say we’re looking for an aws api package right something that will allow us to connect to the aws api and as you see here we get a list of different packages for that to choose from so basically pipey is a repository or storage for all of those modules and packages and people can also publish their own libraries like individual developers for example they can publish their own packages and modules there and make it available for other programmers to use and that’s one reason why large community is so great for a programming language because then you can make use of all these modules and packages that others in the community have developed so for any kind of functionality you need in your application you could imagine that there is a module or package that helps you do exactly that now let’s say i need a django package for my web application so first i find the package and now i can actually check some of the documentation for that specific package so if i click inside i see some description for the project as well as documentation and some other links now the question is how do i actually install this package locally so that i can use it in my project in python we install packages using a package manager tool called peep and right here on top below the package name you actually see a command peep install django so this is actually a command that will install that package locally on my laptop so we install packages in python using this pip command so what is this command or where does it come from pip is a package manager for python and if you know any other programming language basically the concept is the same every programming language has its own package manager tool for javascript it’s npm for java it’s maven or gradle and for python it is pip and one of the main tasks or usages of a package manager tool is to install external packages or libraries or also called dependencies for your project so if python needs this django package basically it’s the job of the package manager to install that package and make available for python now where did this command come from do we have pip command available well in python version 3 actually pip is packaged inside the python so when we install the python we actually installed pip as well so basically we’re going to copy this command peep install django and we’re going to execute it actually from the terminal of pycharm so in pycharm editor we have this integrated terminal so this is actually pretty much the same terminal as you have outside like this so we are going to execute this pip install command directly in this pycharm terminal so i’m going to copy it here and do peep install django and you see it is downloading and successfully installed django 3.1.6 and we can actually see that package from our editor directly if i expand these external libraries and site packages and scroll a bit down here i have django 316 version installed so i see that the package is now available in my project and to also test it in the code i can do import and django and you see that pycharm actually recognize that i have django packaged locally so it gives me that package as a suggestion so that will basically import the whole django package so we can now use it in our application here you see pycharm actually noticed you are using or want to use django web framework as i mentioned in the beginning the pycharm professional edition has special support for different python web frameworks supporting you with syntax highlighting suggestions database integration and so on so again if you want to try it out for free for three months just use my code in the video description in the same way as we install the package we can also uninstall packages using pip and let’s also actually demonstrate that pip uninstall django and let’s confirm that successfully uninstalled django now if in the site packages i click inside you see that django packages are gone so this site packages folder got updated django was removed and you also see that in the code editor now i have this red line under django because pycharm cannot find a module called django and also if i do this obviously it won’t give me any auto suggestion for that so that’s how you can use peep to install packages and also to uninstall packages for your application now here i want to show you another cool alternative to installing and uninstalling packages directly in the pycharm ide and this is actually a feature in the latest pycharm release and for this i need to switch to an early access pycharm version so you see here it says pycharm eap early access to show you the feature however when you watch the tutorial it probably will already be included in the latest official pycharm version so you should have that already so instead of us basically finding this package in pipey and then executing peep install commands right here what you can do is down here you have another tab called python packages so if we click inside this is a place where you have everything that you need to know about the package the package search and all these features basically in one place so for example in order to install django we can just search for django right here and you see that when i type in the first couple of letters i already get suggestions so this is a list of all the packages that start with this name that are actually available in pipi so let’s type in django and we see that right here and on the right you see the documentation of the package that you would actually see in pipey ui so you have that in place as well and in addition to that what they added is the documentation link so this is actually the package how-to guide and the full documentation with examples etc so very convenient way to basically get all the information about the package search the package and then to install the package we can choose the version here so either you can leave the latest or basically select the specific version and then once you have selected that you can just click install and here you see installing package and there you go so now in installed view here so we just had pip and setup tools these two things installed and right here we have now django in the installed packages list and again while you’re now using the installed package or library in your code and basically you want to look up some examples or you want to check some documentation right you go back to the package click inside and you have link to documentation and the package information as well and also just by looking at this list you know which versions of which packages you have installed so i think it’s really cool way to manage all your packages to install packages and for example if you want to uninstall packages from your project then again just clicking to that specific package right here you can just delete it and it will be removed from your application like this and no django anymore here so a very cool addition to pycharm because this will be very convenient to work with the packages so now i will switch back to my other editor again and continue from there so basically i have just cleaned up my python project we have this main.pi which is empty and we’re gonna write an application that will read a spreadsheet file from our local file system it will read some information from that spreadsheet file and do something with that data and this could be a very useful use case if you’re working with lots of files and you want to do some data processing in those files and you don’t want to do that manually by automating or writing a program in python that basically can do anything in a file or across multiple files so let’s see exactly what we are going to be doing with this program so first of all we’re going to have an input file a spreadsheet file that we’re going to be working with and that spreadsheet will look like this it’s called inventory that’s how it’s going to look like so basically this file simulates something that many companies would have and employees of that company would be working with so we have this list of product numbers inventory for each product price for the product and a supplier so this could be an example file from a company that is basically dealing with selling or buying products so what we’re going to do is we’re going to read the information from this file and we’re going to do something with that information first we’re going to write logic that calculates how many products we have per supplier so we have three supplier companies here and per supplier we’re gonna calculate number of products from that specific company and as a result we’re gonna list the company so all three companies with their respective number of products then we’re going to write another logic that lists inventory products that have inventory which is less than 10 so basically those ones the third exercise is going to be to list each company with their respective total inventory value and finally in the last exercise we will calculate the inventory value for each product so product count times price and we’re going to write that value to an additional column in the spreadsheet and after that we’re going to save that updated spreadsheet file programmatically using python so we’re gonna see how to update a file and then save it programmatically in python if any of these sounds a little bit too complicated for you then just bear with me i’m gonna explain everything step by step and it’s gonna become much clearer when we actually start writing the logic so the first thing what i’m gonna do is i’m gonna take this file that i have in the downloads folder and i’m actually gonna move that into my project so i’m gonna copy that and i’m gonna drop it in here so that we have the file right in our project and so we can basically just read it easily and okay and here is our inventory file so that’s taken care of so obviously what we want to do now is read that file so basically let our python program read the contents of that file right here because we want to write some logic based on the values that are in this inventory file right we want to calculate stuff we want to list some stuff and so on so basically we want to work with these values and in order to do that we need to read all of these values into our program so that we have them available so how do we do that now there is actually a built-in module in python that allows you to work with files generally right it’s not specific for a spreadsheet or for any other file type it’s for different types of files generally however there is an external package that allows you to work with spreadsheets specifically and the obvious advantage is that that external module that allows you to work with spreadsheets or was created to work with spreadsheets specifically has much more functions and is much easier to use if you are working with spreadsheets compared to this built-in file module so that’s one of the cases where you may have multiple ways of actually implementing some functionality for application and then you have to make this decision of maybe finding a better package or better module which is available externally that will make it easier for you to implement that functionality so that’s what we’re gonna do for our project we’re going to choose the package that is actually made for working with spreadsheets we’re going to use that one and it’s called open pi xl and if i search for it this is the package that we’re looking for and if i click inside basically we have some information about this package so here we see a description let’s actually make this bigger description library to read write excel files with all these formats so this is the library that we’re going to be using in the same way as we did before we’re going to copy that command and execute it from pycharms integrated terminal so from here i’m gonna execute this pip command and install our module and as you see successfully installed open pi xl and this is the version of the module that we installed and in external libraries site packages you should be able to see our open pi excel package and now because the package is available locally i can do import and open pi excel again i get a suggestion from pycharm because the module is there and now we are able to use that package for our application and one small note here if you’re wondering why there are some packages with basically a dot inside and some without these are the packages that we install python packages and we know that because there’s this init python file inside and the ones without the dot they’re just folders with bunch of files inside but they’re not python packages so to say and inside some of those packages we see other packages as well with their own init file so basically hierarchy of multiple packages and at this point i’m going to say that the word library basically describes package that includes multiple other packages so basically which has a hierarchy of packages so we have module which is basically just one python file that we can use in our project then we have package which is a hierarchy of multiple modules with an init python file inside and then we have library which is basically multiple packages together in a hierarchy just like we see right here so note the difference so you don’t get confused when you see library package and module especially if used interchangeably great so now we have our module in place so let’s use it now to read our spreadsheet file and again you basically have to know the function names to do that if you don’t you can do dot and get suggestions and load workbook is actually the function that we need in order to read our spreadsheet file so i’m going to choose this function and obviously we need to tell this function which file it should read so as a parameter we’re going to say please load inventory file and we even get a suggestion because we have this inventory file here and there you go now this function will load the workbook and all its contents and later we obviously want to do something with that content so in order to be able to do that we need to save it first as a variable and let’s actually call it inventory file like this and this will give us the file contents now let’s actually open that file again and let’s see exactly what we need so we can have multiple such sheets basically per file so we need to tell the program which one it should use exactly so for example if this was called a product list you would use that name but we’re gonna go with sheet one so we’re gonna use that name basically and we’re gonna grab that using following syntax and you remember this syntax probably from using a dictionary so this will give us this one specific sheet and all the information inside and we can also save that into a variable so let’s actually call that product list so now we have read the whole file then we have read this specific sheet of that file and now we have all this information in that variable so now we can read any of those values and do calculations etc using that variable so let’s get to our first task and the first task is basically to calculate how many products we have per supplier and then list the names of the suppliers with that respective number of products so let’s go back and do that so the results what we want to get is basically products or number of products per supplier right that’s basically what we want to get as a result so we’re going to create that variable and we’re going to set it to an empty dictionary so by the end our program should give us something like this a dictionary where the name of the company is the key and the value is basically product count for that company and since we have three suppliers or three companies we’re gonna end up with a dictionary with three key value pairs per company so we’re starting with an empty dictionary for products per supplier and now let’s see how we can programmatically calculate this first of all what we need is we need to go through each of these lines basically so we have these rows so we need to go through each and every row in order in sequence and we need to get or check a supplier name for that row and you remember whenever we execute a logic on multiple values over and over again so basically same logic or same function gets executed for multiple different values for a number of times that’s basically a use case for a loop right so we’re looping through those rows and we’re doing the same thing per row which is getting the name of the supplier now as you also remember loops have conditions right we need to tell the loop how many times it should execute that specific logic and if we check our file here how many times we want to execute the logic the answer is as many times as the number of products so if we scroll down we have 74 products so we need to do that 74 times for each product so basically as many times as the number of product and obviously we want this program to work for any spreadsheet file right with any number of products so we need to calculate or we need to read that value also from the file so basically we need to read how many products are on this list so let’s see how we can do that first of all we’re using for loop to execute the logic for specific number of times and if you remember from for loop syntax four then we have the specific item so what is an item in our case our item is a row right product row is going to be an item of iteration so looping basically so we can call our item products row and then comes in and now we need that condition how many times and again this should be generic so we need to calculate or we need to read the number of lines here number of rows here from the file and the way we can read that is remember we have all the information we need in that one specific variable which is product list and that variable has the value for number of rows which is called max row now how do i know that max row attribute is available for product list i basically just looked it up on the documentation of the module and as i previously also mentioned whenever you’re using a module this module will have a documentation so if you need some functionality if you need some values you can basically just search inside the documentation which functions and variables are available to get the functionality or values that you need and we can actually test it we can print it out like this and as you see here 75 so basically max row will always give us the number of lines or number of rows in that specific sheet so we know how many times to iterate now whenever we’re providing a specific number in a for loop like 75 for example in this case we need to put that number in a range like this so we can’t just say 70 or in this case max row now why do we need a range here and why is number just not enough because the for loop is for iterating over a list and the range will create a list of numbers to iterate through in our case range of 75 will create a list of numbers or sequence of numbers from 0 to 74. and with that we’re going to have a valid for loop where for each item in this list of numbers some logic will be executed so that’s why we need a range here and now there’s one more thing that we need to fix we go back to our spreadsheet you see that the first row so this is going to be the first row basically does not actually include the product information it just includes the titles for each column right so we actually do not want to read this line we want to skip it and we want to start from the second row so instead of starting for loop from the first row we want to start it from the second row and in order to tell python to start at row 2 in the range function we’re going to pass first parameter 2. so basically this will give us a new range of numbers starting from 2 instead of starting from 0. and since we’re using those numbers in the range as an index for the rows the first number is going to be 2 so we’re going to start iterating from the second row so this will be the start point and this will be the end point so basically from here to the end now there are two things specific to a range that you should be aware of first of all when we do not provide the start index basically the start number in the range by default it’s actually zero so it’s not one but it’s zero and obviously we don’t have a line zero here so if we executed it with the default one we would get an error so that’s one thing to consider that range actually by default starts at 0 and not 1. but for us it doesn’t matter because we’re skipping the first one anyways and we’re starting from line 2 because our spreadsheet doesn’t have line 0 obviously another specific of the range is that the second value here basically the last number of execution in the loop in our case this is going to be 75 because we have 75 lines and we printed that out here that number is actually exclusive it’s not inclusive that means that the range will execute from line 2 to 75 exclusive so basically till here this line will not be included in the loop again that’s a specification of the range which we need to fix and basically want to tell you know what we want that iteration including the last number as well including that max row and a simple fix for that is going to be to do plus one here so basically whatever the max row is we want to include that one as well so we want to add one to it so now we have a range starting from two and ending in 76 exclusive so obviously the 76th line will not be red and this will now give us a range that we need and now that we have condition for the loop and we have set how many times it should execute let’s actually execute the logic itself so what is the first information we need from that product row for each row we basically need the supplier name so that we can increment or start counting how many products this supplier has so we need this one two three fourth column and the value in that fourth column for each and every row right let’s go back to editor how do we get a value in the cell you have to imagine when we iterate we have one row per iteration so right here we actually have this product row which is just one row and we have four columns here and we want value in this specific cell and we can get it using first of all product list because again we have all the information here so in this list we need a cell right we need a value of a cell so that’s the name of the function and the cell basically takes two parameters again product list contains the whole sheet here so the whole list with all the rows and columns and we can get a specific cell value so whatever we are doesn’t really matter from that variable by providing two values the row number and the column number that’s it so row nine column one basically will be this specific value row five column four will be this specific value so for each iteration we’re gonna do exactly that so for our case the supplier is always column four and the row is dynamic because we are iterating and therefore we’re going to use whatever row we’re at at the current iteration so that’s the first parameter and column 4 as i said and this will give us the supplier name for each and every row so we can grab that value like this and this is going to be supplier name so we can save it in a variable as a next step we’re going to start building how many products each supplier has we’re going to start building a dictionary with the name of the supplier and then how many products they have so we’re going to be building this dictionary here so this is a reminder now for what i said previously that you don’t need knowledge of math in programming rather you need logical thinking right so you’re going to get tasks like this where you have to basically logically decide how you are going to do a certain task and think all this through right so programming is more about logic rather than pure calculation or math which is actually more interesting and cooler and that’s exactly what we’re going to need in this example we’re going to need some logical thinking to basically build this application so bear with me on this one the first thing we need to check here so think about this iteration on the first time and second time the first time the list or the dictionary is actually empty so we want to add the first supplier to the list right away right so we’re gonna grab that and the syntax for adding a new entry in a dictionary is like this where we have a key and a value here so basically what we want to end up with is supplier name like a company and number of products for that supplier that’s the dictionary that we want to end up with then it’s going to be bbb company and so on so the very first supplier goes directly into the list and we’re going to need the name of that supplier we don’t know what it’s going to be so name as a key and value is going to be 1 at the beginning right this is the very first iteration so after the first it iteration we’re gonna have the first company name supplier name and count one for that on the second loop second iteration basically if the next line is a different supplier like here for example then a new entry will be added because we have a new key now with count one right so now we’re gonna have company a with one product company b with one product now what happens when on the next iteration we get company a again right what we want to happen is company a the product count to increase to two right because now we found another product that is supplied by the same company however with this land we are actually overriding and setting it back to one so how do we make sure that number of products gets incremented instead of always setting it to one what we’re going to do is before we execute this line we’re going to check is it a new supplier or an existing one because that makes a difference so how do we know if it’s a new one or an existing one we can look that name up in the dictionary if we have already edited that name in the dictionary then it’s going to be there and we can do that very easily again with the syntax if supplier name in the dictionary it’s actually very readable syntax that says is the supplier already added to the list or is it a new one so if this is true again remember if conditional so if this is true statement if the supplier name is already there then it is an existing one so we need to increment the product number instead of setting it to one so instead of assigning a new value we want to grab that value the existing one and basically add one to it right just increment by one so getting a value from a dictionary you probably remember the syntax already using the key and we can save it into a variable let’s call it current number of products like this remember we’re using a key in order to get the value and the key is the supplier name value is the product count so this will give us the current number of products on the first iteration this will be one or after the first iteration we’re going to have one product for that specific supplier and if we already have that supplier in the dictionary we want to increment the number of products for that specific supplier by one because we just found another product from that supplier so we want this value to now be plus one right so current number of products plus one so that’s the new value that we want for the existing for this current supplier and how do we assign it back to the dictionary again we grab that and assign it so as you see taking the value from the dictionary has the same syntax as setting that value in the dictionary in fact we could actually use a shortcut here so instead of current numproducts we could just take that value and add plus to it and then set it back as a new value and this will basically just give us a one-liner for the logic depends on the taste whether this looks nice or not or whether it’s better to have a new variable and increment the value like this let’s actually leave it like this so this logic will take care of adding a product count every time we find another product for the same supplier however now we have to decide what happens when it’s a new supplier so if this condition is false if the supplier name is not on the list and this is going to be the case on the very first iteration as well because the dictionary is basically empty so there are no supplier names and for that case else we’re going to do what we had before which is just setting that number to one right this is going to be the first value so this will do two things basically it will create a new entry in this dictionary for this new supplier and it will set the product count number to one for that new supplier and that’s it that’s actually our logic and let’s actually try this out and print it out so right here i’m gonna print adding a new supplier and this is going to happen three times because we have three suppliers so we can safely print it because just gonna happen three times there is one more thing we need to fix here and that is getting the value from the cell so if we actually execute this now let’s comment this out and actually print out what the supplier name here is let’s actually get rid of this line we don’t need this and run the program you see here we have cell information so it’s not actually the the value the name of the supplier but it’s just the object cell and the reason for that is because we’re accessing a cell but we’re not actually extracting or getting the value out of it and we can do that using this value attribute on that complete object again something that you can look up in the documentation of this open pi xl module so now let’s run it again and now we have the actual values of that cell and this will take care of that small problem and now we are ready to execute our program and after the for loop actually let’s print out the dictionary because we want to see the results of the dictionary that we are building here and i’m going to execute it now and there you go first of all we have three times adding a new supplier because we have three suppliers and this is the resulting dictionary and it looks actually very good first we have company a because this was the first on the list and we have number of products that were counted for that company then we have the second one with number of products and the third one so it looks like our program did exactly what we wanted so that takes care of the first exercise now i want to note here one small thing which is an alternative syntax for getting values from a dictionary which is actually a more recommended way of doing it which is instead of having these brackets here to have a get method right to use a get function with the key name so now you see the difference between those two so this is setting the value of that key again remember key is this one here and this is the value so we are accessing the value of the dictionary using that key and get function is actually another way of grabbing this value out of a dictionary using the key name again if i execute this i should see the same result after the first exercise basically we see from which company from which supplier we have the most product or the highest number of products now in the second exercise we’re going to calculate the total inventory value per supplier meaning in our list for each product we have number of units for the product and the price so basically for each supplier we want to calculate how much is the total value of inventory of their products of all their products and again as a result we want to create a dictionary that basically tells us that value per company let’s go ahead and do that so this was calculation calculation for number of products per supplier and here we’re going to give us some space and do calculation total value per supplier or total value of inventory per supplier that’s what we want to calculate so just like we did before we’re going to create a new dictionary now and we’re going to call it appropriately total value per supplier and start with an empty dictionary again for starting in an easy way let’s consider the first very first iteration for the first supplier how are we going to calculate for the first supplier for the first product so i’m going to take this new dictionary and with our familiar syntax i’m gonna do supplier name so that’s gonna be our key and the value of the very first iteration for the first product is going to be inventory times price so for the first product we’re going to calculate how much or how many of the product items we have and number of price right that will give us value of the total inventory for that one specific product and that means we need those two values right now we’re just getting the value of the supplier so we need inventory i’m actually going to copy this so we need cell for product row and column inventory is on column two and value so whatever the product row is going to be so for each product basically for each row we need always the second column so all these values here and then we need price which going to be product list cell and we are looking for the third column for every row number three and value so now we have inventory and price per product and the way to calculate value is basically inventory that’s the number of product items times price very easy that will give us the first value for the first supplier now again the same way if we are getting a new supplier so basically in the next iteration if it’s a new supplier then this line will get executed and everything is fine however if it’s an existing supplier that we already have in the dictionary then we have to add to that previous value right instead of setting a new one so we’re going to do very similar logic as we did here so we have the supplier name we’re checking is it a new supplier or an old one an existing one this time in our new dictionary and if it is we’re gonna grab that old or existing value again using this get syntax here existing value now is hundred we want to add to that hundred right so we’re gonna grab that value this is going to be current total value and then we’re going to add to that current total value the inventory value for the current product and assign it back to our dictionary now our variable names a little bit long so the code kind of looks a bit cluttered but it’s easy to read and descriptive so you can also go for shorter variable names to have a cleaner code again matter of taste i usually name the variables something descriptive something that basically really differentiates or says what the value is about and that basically takes care of existing suppliers or the suppliers that we already have in the dictionary else we do this and this is complaining about too many blank lines so let’s fix that and that’s basically our logic again to go through it once for new suppliers again this is going to happen three times because we have three suppliers we are basically setting the total inventory price or inventory value for that specific product because remember we are iterating through products and then every time a new product iteration happens for the same supplier we basically just add an inventory price or total value for that specific product for what we already have in the dictionary for that specific supplier so now let’s again print out our dictionary let’s actually print both values so the first dictionary is this one right here supplier and number of products second one is going to be supplier and total value of all the products they have in the inventory with us execute and there you go we have both dictionaries printed here and here you see for each company we have the value in price basically right here the value for the total inventory of all the products they have on this list and we see that value per supplier and the values are decimal numbers with cent precision so 95 cents 47 cents because the prices are obviously like this as well and if you’re wondering this comma here is actually a german format for number precision so this is going to be actually equivalent to english dot and we don’t have to worry about this actually because python reads it and interprets it correctly so no problem with different language formats so that takes care of our second calculation now the third logic we’re going to write is basically printing out all the products that have inventory less than 10 like this ones here for example so the logic for that is actually going to be pretty easy what we need as a result is again a dictionary let’s call it products which have inventory under 10 like this and the value in the dictionary should be the product number which we have in the first column and the inventory count so let’s get rid of these print statements and let’s do calculation or we can do logic products with inventory less than 10. so basically as i said for each product which has inventory under 10 we want to print out or we want to save in a dictionary the product number and the inventory count so we have the inventory count already the value from the cell but we don’t have the product number we’re not accessing it so let’s actually do that product number and we already know how this works this is going to be the first column right this one here and this gives us product number and now in our dictionary products under 10 we want to add value like this product number and it’s going to be set to value of the inventory like this however we don’t want it for every product we wanted only for products with inventory less than 10 and that’s going to be an easy if conditional here if inventory again remember this logic all this logic happens for each product row right so all these get executed for each of these rows so basically we have inventory number on each iteration for each specific product and that’s why we can just say if inventory is less than 10 so if the value on that specific row is less than 10 we want to add that product the current product that we are iterating on on the list and set the value of inventory as well again we have some complaining here because of the lines and this will be the logic basically and a use case for this type of calculation would be if we find products that have inventory which are less than 10 means we need to reorder them right because they’re going to get out of stock soon and now at the end let’s print the list of all the products that have inventory less than 10. so i’m going to execute it and here we have the product number and inventory count so we have three products basically which have inventory less than 10 and let’s actually check that product number 25 right here which has inventory of seven and product number 30 inventory of six and the third one as well now you’re probably wondering why we have this dot zero here because by default those values are interpreted as float numbers and not integers if we wanted to we can actually fix that using the integer function in both cases like this let’s execute it again and we have the integers and not floats and finally as a last exercise what we’re going to do is we’re going to actually add some value inside that spreadsheet till now we have been reading the values and doing some calculations and just printing the result on the terminal as the last exercise we’re actually going to create a new column here for every row and we’re going to calculate basically the total price of inventory right the number of units times the price and we’re going to basically set the value for each product inventory multiplied by price so how do we add a column or how do we make changes to a file it’s actually pretty easy the same way as we were grabbing the value from this file and basically reading the values we can add values to it and add columns and rows etc so to add a fifth column we’re gonna do product list cell product row this is going to be the number of the row and a column number so the same way we accessed the cells for all other values we can basically access the cell on column five which has an empty value right so we’re not actually creating a new column we’re just grabbing a value of a column five which happens to be empty and we are overriding that value and we could do the same actually for any other columns here right we can overwrite all these values if we wanted to so that’s basically what we’re doing so we’re grabbing that cell and we can now save it into a variable let’s actually call it inventory price so now that cell is saved into that variable so we can reference it and note here that i didn’t add dot value at the end because if we want to update the cell we need the whole cell object right so that we can actually set a value on that so how do we set a value for that specific cell so again note that this is iteration so for each product row the value will be set so how do we set the cell value i’m just going to grab this variable here inventory price which is representing the cell in column five for each iteration and right here at the end because this is our last exercise let’s write this is a logic or basically add value for total inventory price and the way we set the value in a cell is dot value equals and the calculation for that is actually very easy we already did it here inventory times the price for that specific product and that’s it so we’re using that dot value here in order to set the value instead of grabbing the value and that will actually update and add this calculation a result of the calculation on each line on this column but note that this will only change the value in a temporary file but it’s not going to save anything right so what we want to do at the end if we want this change to persist to actually be saved we want to explicitly save the file so for example if i manually did something here added some value i would need to save it here as well right so that’s exactly what we need to do here but programmatically using python so how do we save a file using python again this package or this module that we use here also gives us a function that we can use to save the file and since we’re doing an operation on a file and not a sheet here we’re going to grab that variable in file and here at the end we’re going to call a save function on it and this will save the file changes however we’re not overriding the same file the existing inventory file we’re creating a new one and because of that we need to provide a name of the new file that is going to be created with the save function and we’re going to call that file let’s say inventory with total value and extension the same extension as we have here so this line will now save the changes and create a new file from the original one which has these values generated basically so now that we are done with the fourth exercise let’s actually print out everything that we’ve done so far i’m gonna take all those values so this is going to be execution of all our logic printing these three dictionaries here and then updating the spreadsheet file and saving it into a new file so with this let’s actually execute our program and see what happened first of all we have all those three dictionaries listed here or printed here with the values and if we pull this aside here you see a new file got generated with the name inventory with total value and if we open this file we should see that for each row a new column was generated and filled with values which is calculated for each product’s inventory and price so that’s basically our project that’s how you work with files in python specifically with spreadsheet files and as i said at the beginning this could be actually very useful automation logic when you’re working at a company where there are lots of excel files or spreadsheet files that employees have to work with and manually update stuff inside in this part we’re going to learn the concept of objects and classes in python and generally object oriented let’s consider an example of an application with lots of users for example linkedin right we have users and each user will have some information for example email address name of the user password maybe a current job title work experience a set of skills and so on right so each user will have all this information but obviously the actual values the actual information will be different for each user in addition to that users are able to do something with their own information right so for example a user can change their password change their current job title add a new skill and again basically do stuff with their own personal information and our program will be able to handle this user information plus user changing their information right so this will be user data and in order to do something so to perform some action we would have functions for that right so all of these will actually be functions however as i mentioned every user will have their own data and whenever a new user basically registers for an application all these data should be gathered for that new user and saved in the application so basically that means that in our program we need some way to define kind of a blueprint for a user for all the data user information and user behavior right things that the user can do in the application because if we have thousand users in our application obviously we can’t write the same logic and same variables thousand times right we want to have a blueprint once and then we can use the blueprint for all those thousand users and that blueprint for a user is called a class and the specific implementation of that blueprint is called an object so think of this like a blueprint of a building right you can have a blueprint once which is like a general description of building with doors and windows and everything that every single building has and then the specific implementation of that blueprint will be the actual built ready buildings right so that’s the same concept we’re going to create a class blueprint for a user and the user class blueprint will define what information a user has and what actions user can perform in the application and object then will contain the actual information like this information right here for each specific user so let’s clean all these up and let’s now actually create class user so let’s create a new file in our project and let’s actually call it user dot pi so this is going to be our user class and inside that i’m going to paste in this piece of code that basically will represent data for the user and some behavior these pieces of data are also called attributes for that class so now let’s turn all of these into a class so first of all we create a class using class special work and you also see the syntax highlighting and we’re going to call that user and you know the syntax already for functions um etc with indentation so this is going to be where our class definition goes now note here the capital letter for u for user and lowercase user in the python file name so a standard convention is that we call classes with a capital letter and the file names are written in lowercase letters and now all of these should actually go inside that indentation right like this now we said that class is a blueprint for specific objects and blueprint cannot actually have specific values right so all these needs to be removed so in the blueprint we don’t have any specific values we just have the attributes so basically we say this user will have an email name password and current job title the actual values of those attributes will be then set when we create an object from the blueprint however we need a function that will actually take those specific values and assign them to an object which is created from the blueprint and we’re gonna create that function right here in the class and that function actually is called init with underscore or two underscores at the beginning and at the end a couple of notes here first of all you see the syntax highlighting just changed to this different color second note is that these functions that start with underscore in python are special functions so python basically gives them some special meaning so it knows exactly what this init function is and we also have to call it init we can’t just call it whatever we want and final note is that this init function in python is something called a constructor again we have a blueprint and we’re constructing objects from the blueprint and this init function the constructive function will help us construct objects from that user class and now for a function syntax you know that we use these brackets right and when i start writing the bracket you see that self got automatically created as the parameter here and the reason is as i mentioned python knows what the init function is and that it’s a constructor so it knows that it needs this self as a parameter again self is also a special word in python it has a special meaning and it actually refers to this class here right this entire class if i hover over it you see self points to the user class and it will basically just help us access and reference all the attributes and functions within that class so it’s for special usage within that user class and we’re going to see examples of how to use that in a second now you can think of those attributes as variables within the class because they belong to the class right they describe basically what attributes or what characteristics this class has and in order to define that these variables belong to the class we need to use self here so and you see again syntax highlighting changed and the red line disappeared so basically we are defining that email name password and current job title belong to this class using this self keyword and now the last thing remaining in this constructor again remember constructor is to construct new objects so whenever a new object is created the specific values will be assigned to all these four variables right and those values those specific values will be passed into the constructor as parameters so email name password and current job title those four values must be provided to the constructor whenever we’re creating a new object note that these names here could be different from this these are not the same these are just parameters and using these parameter values we are going to basically set the variables or attributes of the class like this and the warning is gone as well again as i mentioned this could be something else we could call it user email so it doesn’t actually have to be the same it’s just for convenience so this function will construct an object with parameters that we provide when we actually create it and we’re going to see how to create an object later this is just the definition as remember when you define a function nothing actually happens until you call or you use that function so right here we’re just defining that function so that we can use it later so constructor logic is done now we have these two functions that any user in our application can do right any user can change their password or change their job title and logically when change password happens by user basically user provides a new password in order to override the old one so the flow will be following the object will be created for the specific user so the initial data for that object will be provided so we’ll have the user email name password and current job title and later at some point user may decide to change their password and their current job title and that means the initial data will be changed and that means that we’re actually changing the attributes self.password with a new password right so logic will be like this now we have red lines here why because we need this self as a parameter first of all we also have that as um note right here so just like here we need to actually pass that self as a parameter that’s just how it is because we need to access attributes of that class in that function and new password will be new password variable will be the new password basically that user wants to set so this will change the initial password with the new one and the same way in change.title we have self as a first parameter we always need it in all the functions because otherwise we cannot access the attributes in the class and new job title so now let’s review this class that we created first of all we have this class keyword here with a capital letter for user you already know the syntax with colon and then indentation so this all of these inside this indentation is class body so part of the class logic first we have this init constructor that sets the initial values of that class attributes whenever we create a specific object for that class right so this happens only when we construct a new object and then on that constructed object we can change password we can change job title and note that right now we have nothing basically hard coded we have no specific values here right everything is just parameterized and also this is just a definition for class and its functions nothing will actually happen when we execute this because we’re not creating any user objects so if i right click here and execute this run user you see that nothing happened because the class definition was created but we’re not doing anything with that class definition we’re not creating new users so now let’s actually go ahead and do that in the same file in user.py i would actually use that class blueprint to construct a new user object and creating an object from a class is actually very simple we just write name of the class and parentheses this is actually the same syntax as calling the function with parameters and the parameters that we need to give that class are these four values here and note that calling this user class function basically in the background we’ll call init function right so the constructor will be called whenever we write this syntax with class name and parentheses and this init constructor as you see expects four parameters so we have to provide all those parameters right here in the parenthesis so let’s actually provide them let’s do user email like this my username and password and a current job title again very similar to calling a function and this will actually construct a new object from the user class which has these four attributes with values that we just provided here and has these two functions that we can use to either change a password or change job title one note here is that functions that belong to a class are actually called methods so there’s a special name for functions which are part of a class so we can refer to them as methods so user object basically gives us two methods that we can use now again if we execute this program now we will not see anything even though user will be created because we’re not printing anything to the console we’re not doing anything so let’s do that run user nothing happens because we need to print a message or some kind of information so what i’m going to do now is inside that class i’m going to create a function or a method as we learned now that basically prints back some user information right prints me the name email and current job title because we don’t want to display password so let’s give us some space here and let’s create a function called get user info so that we can see something and again as soon as i typed in these first parentheses self got generated because we need self in every function within the class and in the function body we’re gonna print user information so let’s say user and name of the user which we can access using self remember all the attributes that the object has can be accessed with this special word here so self dot name so user whatever the user’s name is currently works as a and now we need the job description or job title and you can contact them at and now we can use the email so this message will be printed for the user again because this will be used for any user of our application the message these parts will be the same but each user will have their own different name different job title and different email address so all of these are and written as variables because we don’t know these values up front so now we can actually use this function or method to print out information of a specific user so how do we use or how do we call that function of the user we first save it into a variable app user one or nana doesn’t really matter let’s call it app user one so it’s generic so how do we use that function to print out the information about the user if i do app user one and dot you see that i have the attributes here the four attributes that our user object has or user class and we have these three methods of the class get user infor change job title and change password so using get info we can call this function and if i execute this right here you see user nanogenasia currently works as a devops engineer you can contact them at this email and now let’s say we want to change job title of that user we do that in the same way app user one dot change job title and we’re gonna provide the job title parameter note that even though you see two parameters here on that function this first parameter is passed in automatically so we don’t have to basically pass that self right it’s already done automatically we just have to worry about these parameters so new job title is let’s say devops trainer and now we can call that user info method again and execute and you see first message printed here before we change the job title now it’s devops trainer so that’s how we can create a new object from a class and we can use methods of that object by first saving that object into a variable and then calling that function on that variable and obviously now this is just one user but if we had another one user two that’s actually clean this up we can create a new user with different values like this they have their own email own name own password and on job title and again we can create that user and basically just use the methods defined in the class and in two different cases or for two different users obviously the user info will be different so let’s execute this and right here you see the user information for both users and obviously if you have an application like linkedin you don’t have two users or a thousand users you probably have millions of users and having a user definition once and reusing it every time a new user gets created or basically existing users do something in application is only possible when using classes and objects instead of just having all these logic non-structured throughout the code and again in this type of applications you would not have four attributes and three methods you will have probably hundreds of attributes and hundreds of such methods now as you see here we have created this user.pi file for user class but we’re also creating these objects in the same file which actually doesn’t make sense because the file should be only for defining the class right so all of this logic actually needs to move out from here and this should be just only for class definition so in the application again using an example of linkedin we would have class user and then we would have a class post right whenever someone posts something each post will have their own attributes like the actual message or text in that post the author who wrote the post how many likes it has etc as well as specific functions right for example changing the post commenting on the post etc so you will have separate file for each such class right in the application and then you would have one file somewhere else this could be a main dot pi where you would actually use all those different classes and create objects from those classes and that means that logic that we wrote here constructing a user object and then calling some functions on that will actually happen in another file in our case let’s use main.pi and now let’s see how we’re going to do that i’m going to paste in the code that i copied from there and as soon as i paste in you see those red lines so basically main.pi says that it cannot find a reference to user so this file doesn’t know anything about the user class so how do we fix that or how do we make this user class available in another file and if you remember when we needed to use modules or basically functions variables whatever from other files in python we use import to basically import those functions and make them available here or import the whole module to make its functions and variables available here and the same way we can import classes from another file import user and note here that i’m using the name of the file user lowercase and not the class name with capital user right so we are importing that file so now we can use anything that is defined in that file and one of them is class called user and the way we can access that class now is using the name of module and not the class user itself and this is basically exactly the same concept as we saw before because we are importing a module called user remember every python file that has functions or variables or classes inside is a module so we are importing a module and once we have that module imported now we can use and access functions variables or classes of that module and we can do that by copying the name of the module dot and there you go in the same way here so exactly the same concept whether this is a function or a class doesn’t matter we use it the same way remember when we use the date time module with the syntax datetime.daytime and that was an example of using a class from a module now user.user may look a little bit weird so we can use our familiar import statement where instead of importing the whole module we can pick and choose and import specific definitions or specific elements of that module in our case we just have one element which is the class so we’re going to say from user module import user class and now we don’t need the module name anymore because we imported the class itself and now if we execute main dot p y let’s do it again here we have the same result for two of our users and again as i said in applications you will have multiple classes that are connected to each other so for example if we have a post here post blueprint basically whenever a new post gets created with some specific values like the actual message and creation date time etc it will also have an author and that author will actually be one of those user objects right so you will have some functions here that actually reference the post and we can also see that in action let’s actually create a post class let’s give it just two attributes to keep it simple so we need a constructor here in it and we’re gonna pass in message and author right this is gonna be the user who wrote it and you know the drill already and let’s create another function which displays a post with its respective author so let’s do get post info again we have self here and let’s print post written by and the author name so this is going to be our simple post class and user is able to create new posts so we have the blueprint for a post and the same way we can create that post inside the main dot pi so first let’s import the post class and then here we’re going to create a new post in pycharm you get this nice display of parameters that function or class basically expects so we have message and author let’s do some message or post and as a second parameter we have the author and we can use the name of a user so let’s do app user to dot name and this will create an object also called instance in programming special instance of that post class and then we can print the information of that post first assign it to a variable let’s say it’s a new post and on a new post we’re gonna call get post info let’s actually run this application now and see the result and here we have our post message that gets printed by this get post info method in the post class and at the beginning i mentioned object oriented programming which basically means that when you’re writing your code with objects and classes like this to create blueprints and then use those blueprints for specific instances that’s called object-oriented programming and also an interesting note here is that in python almost everything is actually an object for example the data types like string integer list set etc when we printed them out we saw class of string or class of list so these data types are also classes in python and this int or sdr for string functions we called where actually the constructor we called to create a string or integer object and the constructor of int for example took a string representation of a number and in its init function and constructed an integer out of it now for us in terms of using these data types and variables etc it doesn’t actually matter but it’s just an interesting thing to know about how this whole thing works in python in this part we’re going to learn how to use python to talk to external applications in our case we’re going to use gitlab and then application and just note here that communication between two applications in our case our python application and a gitlab application usually happens using a common protocol like http so basically our python application will send an http request to gitlab application and from the gitlab application it will get an http response for that request so just know that http is just a protocol that these two applications can communicate with over the internet i have a couple of projects on gitlab so we’re gonna write a very simple python application that basically goes to gitlab and asks for the list of projects for my user and then just prints it here in our run window and the concept of one application talking to another is basically done using something called api requests so the remote application in this case gitlab has an api so these are functions basically that gitlab makes available for other applications to call and we’re going to call those functions from our python application in order to get the list of projects for my user and that communication or python basically asking for this information is going to be an api request or api call and what we get in response from this gitlab api is going to be api response so let’s go ahead and do that in python in order to make those external requests to remote applications we’re going to need a module called requests this is a generic module that you can use for any external application and as i mentioned at the beginning the communication happens using http protocol between two applications and as you see here also in the module description it says an http library which allows you to send http requests and then receive http responses from another application and that’s exactly what we’re going to be doing and this request module is not part of python so we’re going to install it using pip again remember that we’re using pip that actually comes packaged with the pycharm so in the terminal window of my ide of pycharm i’m going to execute peep install requests successfully installed request this is the version of that module and if i expand this external library’s site packages i’m going to see the requests package in the list great so once we have the module available locally we can import that module in our file and this requests module now has or package actually has functions variables and objects that we can use to talk to these remote applications like gitlab as i said gitlab is just one example you can talk to any remote application that has an api and we can not only do requests for getting the existing information but we can also make requests to change something in that remote application so for example i can write a python application that will actually create a new project on my gitlab account but to keep the demo simple we’re just going to be fetching information from gitlab so how do we make requests to an api of an application with this requests module we get a function called get and get takes one main parameter which is url so basically we need to tell python where to find that remote application or again in our case where to find gitlab to talk to it so we need the url of gitlab and where do you find this url information of a remote application you can basically google that every application has their own documentation where you can see the urls so for example for gitlab i actually googled it so if i do gitlab api documentation like this let’s make it bigger so you have basically description for the api and what type of information you can get from gitlab and also what kind of things you can create in gitlab and you see an example api here that basically just lists all the projects however we want to list projects of one specific user in this case i want to list my own projects and in this documentation i found this list user project section where i have an example of how to use projects for a specific user so we have slash users and the user id so that’s going to be my gitlab user id and projects so basically the url will now look like this first we’re gonna have this base url so that’s basically https gitlab.com api v4 and all the things that we want to do is going to be at this base api and after that we can basically depending on what exactly we want to do we can choose one specific action and again going back this is the action we want to execute on this base url so from gitlab we want projects that belong to user and right here i’m going to add my own gitlab user id so if you have a github account you should add your own user id here and that’s going to be an api url for user projects and this will actually give us some kind of response so requests.get will make that request to gitlab and it will return some kind of response and we can save that response into a variable so let’s call this variable response because that’s what it is and on the next line let’s actually print and see what’s in that response let’s run our application and right here you see we have an object response with a code here 200 is a code for a successful request but we’re not seeing the actual contents right we want to see the projects with their details and in order to get that we’re gonna do dot and text and let’s actually execute this now and now you see these square brackets which means it is a list because we have a list of projects and this whole bunch of information about projects there and you also see curly braces so this is a list of dictionaries and each dictionary holds information of one specific project now if i actually print the type of that response text like this see that it is a string so even though we see the format is actually a list of dictionaries we’re getting a string because we’re accessing text attribute now there is actually another attribute which will give us the same thing but as an actual list of dictionaries instead of string and this will be actually a better way to get that information because then we can work on it so we can look through it and get the individual elements and access the values so what i’m gonna do now instead of dot text i’m gonna use json json is a standard format that all programming languages understand and usually when two applications communicate with each other which are written in different languages and with different technologies with json they have a common format for communication and this requests module basically gives us this json function to read the json format that gitlab sent us so json function will read the json response from gitlab and turn it into one of the python data types so i’m going to execute this now and now you see that response.json actually gave us list data type instead of string so again for demonstration since this is a list i’m going to access the first element of that list and print that out and right here you see that is actually the first element just the first one from the list and that element is a dictionary as you see so all these just to give you an idea of what we’re getting back from that gitlab api and what we can do with that response or how we can actually work with that response so i’m gonna clean all this up and we saw that response.json gives us exactly what we want and that is a list of my projects so let’s call this variable my projects and now what i want to do with this is i want to print out in our window for each project project name and project url so basically the repository url for that project so i don’t want to have any other values like id or description or whatever other stuff i have in this dictionary i just want name and project url for every single project and i want that information printed out in this window so how do we do that we have a list so we’re gonna loop through that list to access each element inside that list so you remember we have for loop to loop through or iterate through a list and give us access to each element one at a time so here i’m going to write for loop and if you remember the syntax of for loop we have four and then a variable which will represent the single element in that list and in this case it’s going to be a project a single project and then we have in list so for project in my projects do something so for every project element in this my projects list we want to print out the name and the url so right here i will do print and let’s do our formatted string here and let’s start writing our message let’s do project name and the project name will be this one right here now how do we actually access the name of the project in each project element as you see here these project elements are actually dictionaries and how do we access a value in a dictionary using the name of the dictionary in this case our variable project so this whole thing is going to be saved into a variable called project and then on that variable on the dictionary we’re going to pass in the name of the key which is name now i’ve been using double quotes throughout our project and for a syntax for dictionaries as well like this right however here we have a small problem which is we have double quotes inside the double quotes but as you remember for string representation we can actually use single quotes as well as double quotes and this is one of the really important use cases for why we can actually use both single and double quotes for a string and that is if we have a string inside another string like right here we can actually use that interchangeably so that we don’t have this problem here so now as you see back to normal everything works because now python knows okay this is another string which we’re using inside this string so we can use these interchangeably as we want so this could be single quotes and this could be double quotes wouldn’t really matter but that’s a really good use case why we need both types of quotes so we have the project name now we need a project url and let’s see where the project url is in our dictionary this is one element one dictionary right so i’m gonna scroll it to the left and we have web url this is what we could use or we could also use http url to repo let’s go with the web url so again this is a key inside the dictionary so we can access the value so this is actually the value we need and we can access that using the dictionary name projects and the key name which is web url and this is actually project not projects and this code will now print name and url for each project so let’s actually execute our program and as you see we have project name and project url for each project we can make the output a little bit cleaner let’s do a new line here and a new line here so we can separate the projects from each other and run again and there you go this looks a little bit cleaner for each project we have a name and a url so if i click inside i’ll go directly to this project so that’s basically a very simple example of how to use requests module to talk to external applications or external urls and then do something with the response that we get from that external application by first converting that into an actual data type that we’re getting using json function so in our case it was a list and that’s why json function actually converted it into a list if the response was a dictionary instead of at least then json would convert it into a dictionary and then we can do something with that response value congratulations you made it till the end i hope you learned a lot and got some valuable knowledge from this course if you like the course please leave a thumbs up on this video on my channel i actually cover lots of different devops topics like docker ci cd terraform and more so be sure to check out my tutorials if you’re learning python to become a devops engineer i actually have a complete devops bootcamp with all the technologies you need to learn as a devops engineer which also includes a module for automation with python with several cool demo projects to automate some common devops tasks like application and server monitoring cloud automation tasks with aws jenkins etc so if you’re interested check out more info in the description also happy to connect with you on social media so i would love to see you there with that said thank you for watching and see you in the next video
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
Iran International reports on a range of current events. A key focus is Prince Reza Pahlavi’s advocacy for action against the Islamic Republic at the UN Human Rights Council. The broadcast also covers US-Russia talks regarding the war in Ukraine, including potential normalization of relations and possible meetings between Putin and Trump. Economic issues within Iran are highlighted, particularly the impact of sanctions on oil sales and widespread inflation affecting Iranian citizens. The program further explores how the Iranian government spends its money. Finally, the report analyzes how Iranian oil exports work with sanctions in place.
Iran International News Analysis Study Guide
Quiz:
Answer the following questions in 2-3 sentences each.
What did Prince Reza Pahlavi say in his speech at the UN Human Rights Council in Geneva?
What was the main purpose of the US-Russia talks held in Riyadh, Saudi Arabia, regarding the war in Ukraine?
According to Marco Rubio, what topics will be of importance in the ongoing Ukrainian peace talks?
What did the Director of the Center for Contemporary Iranian Studies in Russia suggest about the US-Russia talks?
What is the significance of the past meetings between Donald Trump and Vladimir Putin, as discussed in the broadcast?
What accusations did US intelligence agencies make after Donald Trump’s victory in the 2016 election?
How has the high price of goods in Iran been reflected in Iranian social media?
What is the Iranian government’s view on the austerity of its people?
According to international reports, what has been the impact on Iran’s oil exports since the announcement of the Trump administration’s policy of maximum pressure?
According to Mehdi Mozambi, how does China pay for the oil that it imports from Iran?
Quiz Answer Key:
Prince Reza Pahlavi stated that the time has come to take action to destroy the Islamic Republic and emphasized the Iranian people’s fight for freedom, justice, and human dignity. He also told those who want to silence or stand in the way of Iranian progress that Iranians will not wait for their approval.
The US-Russia talks in Riyadh were ostensibly about ending the war in Ukraine but were, in fact, an opportunity for the two countries to improve bilateral relations, including the resumption of consulate operations.
Marco Rubio indicated that future talks on peace in Ukraine would include discussions of territory and security guarantees. He said that European countries will join these talks at some point.
The Director of the Center for Contemporary Iranian Studies in Russia suggested that the Ukraine issue was an excuse for the US and Russia to resume relations. He also claims that Trump intervened in the war because the U.S. would lose too much (the Middle East, Europe, and the dollar).
The past meetings between Donald Trump and Vladimir Putin are significant because they highlight a complex and at times controversial relationship between the two leaders, characterized by both personal admiration and political tension. It was also mentioned that Trump may have had contact with Putin while no longer in office.
After Donald Trump’s victory in the 2016 election, US intelligence agencies accused Russia of carrying out an organized cyber operation to influence the election in Trump’s favor.
On Iranian social media, people are protesting against the Islamic Republic due to the rising costs of goods, expressing their frustration with the government’s indifference to the suffering of the Iranian people, and discussing the financial and living problems they are facing.
Users on social media have stated that economic austerity is only for the people, but prosperity and growth budget is only for the government.
Reports indicate a significant decrease of 40% in Iran’s oil exports to China since the announcement of the Trump administration’s policy of maximum pressure. This has caused turmoil in Iran’s economic situation.
China does not give cash to Iran for oil; instead, payments are processed through the Central Bank of China in the form of Chinese goods or other issues.
Essay Questions:
Analyze Prince Reza Pahlavi’s speech at the UN Human Rights Council. What are the main arguments he presents, and what impact do you think his words have on the international community and the people of Iran?
Discuss the complexities of the relationship between the United States and Russia, as reflected in the news coverage of the talks in Riyadh and the historical overview of meetings between Trump and Putin. How have these relations evolved, and what are the potential implications for global politics?
Evaluate the economic challenges facing the Iranian people, as depicted through social media reactions and reports on oil exports. What are the primary drivers of these challenges, and how are they affecting daily life in Iran?
Examine the role of international sanctions in shaping Iran’s oil exports and economic policies. How effective have these sanctions been, and what strategies has Iran adopted to circumvent them?
Discuss the perspectives of the Iranian people on the relationship between domestic unity, political movements, and the role of leadership in shaping the future of Iran.
Glossary of Key Terms:
Islamic Republic: The current ruling government and political system in Iran, established after the 1979 revolution.
Prince Reza Pahlavi: The son of the last Shah of Iran, and a prominent figure advocating for a transition to a democratic government in Iran.
UN Human Rights Council: An inter-governmental body within the United Nations system responsible for strengthening the promotion and protection of human rights around the globe.
Marco Rubio: A US Secretary of State involved in US-Russia talks related to the war in Ukraine.
Vladimir Putin: The President of Russia, a key figure in discussions regarding US-Russia relations and the war in Ukraine.
Donald Trump: Former President of the United States, known for his complex relationship with Vladimir Putin and his administration’s policies toward Iran.
Rial: The official currency of Iran.
Sanctions: Economic or political penalties imposed by one or more countries against a targeted country, group, or individual.
Bloomberg News: A major international news agency that provides financial news and information.
Iranian Broadcasting Corporation: The state-controlled media organization in Iran.
Iran International News: Opposition, Economy, and Global Relations
Okay, here’s a briefing document summarizing the key themes and ideas from the provided text.
Briefing Document: Iran International News Excerpts
Date: October 26, 2023 (Assuming current date based on the nature of news)
Source: Excerpts from Iran International broadcast.
Main Themes:
Iranian Opposition and Regime Overthrow: A central theme revolves around calls for the overthrow of the Islamic Republic of Iran and the role of opposition figures, particularly Prince Reza Pahlavi.
Human Rights Concerns: The broadcast highlights human rights violations within Iran, focusing on suppression of protests, political prisoners, and the lack of political freedom.
US-Russia Relations and Ukraine: The excerpts cover US-Russia talks regarding the war in Ukraine, including potential normalization of relations and a possible meeting between Putin and Trump.
Economic Crisis in Iran: The news highlights the severe economic situation in Iran, characterized by high inflation, a collapsing rial, and the impact of US sanctions on oil exports.
Iranian Oil Exports and Sanctions Evasion: The broadcast discusses Iran’s efforts to export oil despite US sanctions, including using smaller Chinese ports and potential illicit activities.
Detailed Breakdown:
1. Iranian Opposition and Regime Overthrow
Prince Reza Pahlavi’s statements: Prince Reza Pahlavi is a major focus, with his speech at the UN Human Rights Council in Geneva highlighted. He argues for decisive action to “destroy the Islamic Republic.” He states, “The time has come to take action to destroy the Islamic Republic.” He emphasizes the regime’s corruption, dismantled “axis of resistance,” and destroyed internal legitimacy as reasons for immediate action. He asserts that Iranians are fighting not only for themselves but for “the values of freedom, justice, and human dignity.”
Call for international partnership: Pahlavi says to those “who want to silence us or stand in our way, we will not ask for your green light. We will not wait for your green light…Our question is, will you stand with us?” showing a clear push for international support beyond sympathy.
Geneva Summit: The broadcast covers a summit for human rights and democracy held in Geneva, coinciding with the UN Human Rights Council. The summit focuses on human rights violations and the struggles for freedom and democracy in Iran. Activists like Farnoush Tabatabaei emphasize the importance of unity and being “the voice of the silent ones.”
Emphasis on Unity: Speakers emphasize the need for unity among Iranians, both inside and outside the country, to achieve regime change and restore human rights. There is a call for different political spectrums to unite.
2. Human Rights Concerns
Suppression of Protests and Political Prisoners: The Geneva summit is presented as a platform to discuss the suppression of protests, the situation of political prisoners, and the future of democracy in Iran.
Focus on specific issues: The broadcast mentions a panel on the “Islamic Republic’s brutal treatment of protesters.”
Historical Context: An activist references the “oppression and lack of political freedom” that Iranians have suffered for 46 years.
3. US-Russia Relations and Ukraine
US-Russia Talks in Riyadh: The broadcast covers talks between US and Russian officials in Riyadh, Saudi Arabia, ostensibly focused on ending the war in Ukraine. The talks are also framed as an opportunity to improve US-Russia relations.
Normalization of Relations: Marco Rubio is cited as announcing Washington and Moscow’s decision to normalize relations between the two countries.
Potential Putin-Trump Meeting: The talks are seen as potentially paving the way for a meeting between Vladimir Putin and Donald Trump.
Ukraine Concerns: Zelensky criticizes any talks on Ukraine that do not involve Ukrainians. The EU also has differing interest in the war.
Trump’s View: Trump believed that he had to intervene to prevent the issue of war. Because if this continues, after a few more years, Russia will win.
4. Economic Crisis in Iran
High Inflation and Collapsing Rial: The broadcast emphasizes the severe economic hardship faced by Iranians, linking it to high inflation and the declining value of the rial. Users on social media express their struggles and criticize the government’s indifference.
Impact of US Sanctions: The report highlights the impact of US sanctions on Iran’s oil revenues.
Austerity for the People, Prosperity for the Government: A user criticizes the government, claiming that “austerity is for the people, but wasteful spending is for the government.”
Low Salaries: There is commentary and criticism of the low salaries being set for employees and retirees. One user states this amount is “not even enough to buy Eid fruits.”
5. Iranian Oil Exports and Sanctions Evasion
Oil Export Decline: Reports indicate a significant decrease in Iran’s oil exports to China following the Trump administration’s policy of maximum pressure. “International reports indicate a 40% decrease in Iran’s oil exports to China in January.”
Discounts on Oil Sales: A member of Parliament’s Energy Commission confirms the “extensive discount on oil sales.”
Use of Small Chinese Ports: Bloomberg News is cited as reporting that Iran is sending oil to “small Chinese ports” to evade sanctions.
Sanctions Evasion Tactics: The report mentions that Iran uses tactics such as transferring oil between tankers and falsifying licenses to sell oil in the Chinese market.
Financial Ramifications: China is mentioned as not giving cash to Iran for its oil.
IRGC Involvement: There are allegations that children of IRGC commanders are involved in setting up offices in other countries to facilitate oil transfers.
6. Trump-Putin Relationship History
Mutual Admiration: Before Trump’s presidency, both leaders had expressed admiration for each other. Putin called Trump a “brilliant” man.
Controversy over Election Interference: Trump has repeatedly denied Russia’s interference in the 2016 US presidential election, even contradicting US intelligence agencies.
Meetings and Closed-Door Talks: The report details previous meetings between Trump and Putin, highlighting controversial closed-door talks attended only by interpreters.
Sanctions Despite Admiration: Despite personal admiration for Putin, the Trump administration imposed extensive sanctions on Russia.
Continued Contact: It is alleged that Trump maintained contact with Putin even after leaving office, possibly through private phone calls.
Overall Significance:
The broadcast paints a picture of a complex geopolitical landscape involving Iran, the US, Russia, and Ukraine. It highlights the challenges faced by the Iranian people under the current regime, the ongoing efforts to address the war in Ukraine, and the intricate dynamics of US-Russia relations. The focus on Prince Reza Pahlavi and the Geneva summit suggests a continued emphasis on regime change in Iran and the promotion of human rights. The economic news underscores the severity of the crisis in Iran and the difficulties the country faces in navigating international sanctions.
Global Affairs & Iranian Challenges: Key Discussions
FAQ
What was the main focus of Prince Reza Pahlavi’s speech at the UN Human Rights Council in Geneva?
Prince Reza Pahlavi’s speech focused on the urgent need for action to dismantle the Islamic Republic, emphasizing that the Iranian people are fighting for universal values of freedom, justice, and human dignity. He called on the international community to partner with the Iranian people in their struggle, rather than waiting for permission or offering mere sympathy. He highlighted the regime’s corruption, dismantled “axis of resistance,” and destroyed internal legitimacy as reasons why now is the time to act. He said that the Islamic Republic seeks war with the world and will not stop until overthrown.
What was the purpose of the Geneva Summit mentioned in the broadcast?
The Geneva Summit was held to examine human rights violations and support the struggles for freedom and democracy, coinciding with the United Nations Human Rights Council. Activists, political figures, and victims of repression from around the world attended. Discussions focused on the suppression of protests, the situation of political prisoners, and the future of democracy in Iran, with Prince Reza Pahlavi being a key speaker.
What were the key topics discussed during the US-Russia talks held in Riyadh, Saudi Arabia?
The US-Russia talks in Riyadh centered on improving relations and addressing the war in Ukraine. Key topics included resuming bilateral relations and reopening consulates, which had been strained in recent years. Discussions about Ukraine involved potential negotiation frameworks, including territory and security guarantees, with the US emphasizing a search for lasting peace. While Ukraine was not directly involved, the US affirmed consultations with European partners, who are expected to join future talks, particularly regarding sanctions.
What is the significance of potential meetings between Vladimir Putin and Donald Trump?
Potential meetings between Putin and Trump are viewed as significant due to the complex and sometimes controversial relationship between the two leaders. They are seen as potentially easing global political tensions, particularly concerning the war in Ukraine. Some believe that Trump might intervene to prevent further escalation and protect US interests, potentially collaborating with Russia to establish stability.
What is the status of Iran’s oil exports, particularly to China, in light of US sanctions?
Despite US sanctions aimed at zeroing out Iran’s oil revenues, Iran continues to export oil to China, albeit with significant discounts. These exports often go through small, private Chinese ports after major ports refuse to handle sanctioned oil. Experts suggest that these private ports have limitations in handling large tankers. The financial benefits for Iran are marginal, with payments often made in Chinese goods rather than cash, highlighting the economic pressures the country faces.
How are high inflation and the collapse of the rial affecting the Iranian people?
High inflation and the collapse of the rial are causing significant economic hardship for the Iranian people. Users are lamenting the high prices of basic goods and criticizing the government’s indifference to their suffering. They contrast austerity measures imposed on the population with what they view as wasteful government spending on religious organizations and state media.
How have previous meetings between Trump and Putin shaped US-Russia relations?
Previous meetings between Trump and Putin have been marked by personal admiration and controversy. While Trump repeatedly praised Putin as a strong leader, these meetings have also drawn criticism due to Trump’s perceived willingness to accept Putin’s denials of Russian interference in US elections. Despite imposing sanctions on Russia for various actions, Trump maintained a connection with Putin, potentially seeking to return to power through these interactions.
What is the role of unity among Iranians, both inside and outside the country, in addressing Iran’s challenges?
Unity among Iranians is seen as essential for addressing the country’s challenges and achieving democracy and human rights. Activists emphasize the need for Iranians, both within Iran and abroad, to unite despite differing political views. Some believe unity is emerging within Iran, particularly within the Women’s Uprising for Freedom, and hope for similar unity among political factions outside the country to support the liberation of Iranian soil.
Reza Pahlavi: Advocacy for Iranian Freedom and Democracy
Prince Reza Pahlavi’s activities and statements are a prominent topic in the sources.
Key aspects of Prince Reza Pahlavi’s activities and statements include:
Advocacy for Action Against the Islamic Republic: Prince Reza Pahlavi stated that the time has come to take action to destroy the Islamic Republic. He has been traveling in Europe, discussing the democratic ideals of Iranians with government leaders. He declared that those who seek to impede progress by demanding silence or obstructing the path forward will not be granted permission or be waited upon.
Speech at the UN Human Rights Council in Geneva: He gave a speech at the UN Human Rights Council in Geneva, addressing the suppression of protests, the situation of political prisoners, and the future of democracy in Iran. The speech was titled “Fight for the Freedom of Iran”.
Call for Unity and Partnership: He emphasized that the Iranian people are not asking for sympathy but for partnership. He has called for unity under his leadership.
Historical Context: It was mentioned that 2,500 years ago, Cyrus the Great wrote the Charter of Human Rights, and there is a desire to see the charter and human rights return to Iranian soil.
Impact of Geneva Conference: The Geneva conference is seen as a platform for Iranians abroad to voice the concerns of those oppressed in Iran.
Views on the Islamic Republic: Prince Reza Pahlavi believes that the creations of the Islamic Republic will only disappear with the destruction and overthrow of the regime, which he sees as more corrupt than ever with its axis of resistance dismantled and internal legitimacy destroyed. He views the regime as seeking war with the world.
Support and Emotion: His speech in Geneva evoked strong emotions, with many attendees, including non-Iranians, expressing tears and solidarity.
Role as Leader: Some consider it a national and patriotic duty to support Prince Reza Pahlavi as the leader of the national movement.
Reactions to Economic Issues: Prince Reza Pahlavi’s statements coincided with discussions about high inflation and economic difficulties in Iran, with users on social media expressing discontent with the government’s handling of the economy.
US-Russia Talks on Ukraine: Normalization and Future Negotiations
The sources discuss US-Russia talks, particularly in the context of the war in Ukraine and broader relations between the two countries.
Key points regarding the US-Russia talks include:
Normalization of Relations: Marco Rubio announced Washington and Moscow’s decision to normalize relations between the two countries. A significant step towards this normalization is the potential reopening of consulates in each country.
Talks in Riyadh: US and Russian officials met in Riyadh, Saudi Arabia, to discuss ending the war in Ukraine. These talks are viewed as an opportunity for the two sides to improve their relations.
US and Russian Representatives: Sergei Lavrov and an aide to Vladimir Putin represented Russia, while Marco Rubio and Steve Jobs, Trump’s special envoy for the Middle East, represented the US.
Future Negotiations: Two teams are expected to be formed by the United States and Russia to advance future negotiations.
Key Issues: Discussions about territory and security guarantees are expected to be important issues in future peace talks regarding Ukraine.
European Involvement: While there was concern that European countries were being sidelined, the White House National Security Advisor indicated that they are constantly consulting and discussing with European officials and that European countries will eventually join the talks, especially since they imposed some of the sanctions.
Russian Perspective: Lavrov stated that Russia will not accept European forces in Ukraine under any flag.
Potential Meeting Between Putin and Trump: These talks are seen as potentially paving the way for a meeting between Vladimir Putin and Donald Trump to discuss the Ukraine issue.
Trump’s View: According to Rajab Safarov, Trump felt he had to intervene to prevent the issue of war because if it continued, Russia would win, the European Union would be destroyed, and the dollar itself would be at risk.
Ukraine’s Stance: Volodymyr Zelensky has criticized talks on Ukraine that do not involve Ukrainians.
Importance of Dialogue: The beginning of the US-Russia dialogue is considered important, especially after approaching confrontation and war.
Overall Significance: The fate of the international community and the issue of global political escalation depends on the US and Russia.
Previous Meetings: The history of meetings between Putin and Trump reveals a complex relationship, marked by both cooperation and controversy. Despite tensions and sanctions imposed by the Trump administration on Russia, Trump maintained a personal connection with Putin.
Iranian Oil Sales Under US Sanctions
The sources discuss Iranian oil sales, particularly in light of US sanctions and their impact on the Iranian economy.
Key aspects of Iranian oil sales discussed in the sources:
Impact of US Sanctions: The Trump administration’s policy of maximum pressure on the Islamic Republic and aiming to reduce Iran’s oil revenues to zero has led to a decrease in Iran’s oil exports. In January, international reports indicated a 40% decrease in Iran’s oil exports to China.
Discounts on Oil Sales: A member of the Parliament’s Energy Commission, Mohammad Bahrami, emphasized the continuation of discounts for oil sales, which has caused turmoil in the country’s economic situation. Sanctions mean that Iranian oil cannot follow its normal routine and will definitely be discounted, possibly more than before.
Destinations for Iranian Oil: Due to US sanctions, the Islamic Republic is sending oil to small Chinese ports. Bloomberg News reported that private terminals in some small Chinese ports have become new destinations for oil purchased from Iran and Russia after China’s major ports refused to deliver it.
Limitations of Small Ports: These small, private ports can only handle a limited amount of oil, around 700,000 to 800,000 barrels per day, and cannot accommodate larger tankers. Tankers under US sanctions are limited to these private ports.
Circumventing Sanctions: These private ports may be involved in fraudulent activities, such as changing licenses to sell the oil to the Chinese domestic market, similar to what was done in Malaysia and the UAE before.
Financial Aspects: The financial return to Iran from these oil exports has always been marginal. China does not provide cash to Iran but instead provides goods or other items through the Central Bank of China.
Role of IRGC Commanders’ Children: Some children of IRGC commanders have reportedly set up offices in Malaysia, Indonesia, and the UAE to facilitate oil transfers, including transferring oil from tanker to tanker.
Economic Pressure: The situation with oil sales puts more pressure on Iran’s economy. The psychological atmosphere created by these conditions also has a negative impact, and domestic brokers may exacerbate this pressure.
Iran’s Economy: Sanctions, Inflation, and Government Policies
The sources discuss the economic conditions in Iran, focusing on the impact of sanctions, inflation, and the government’s handling of the economic situation.
Key points regarding the economic conditions in Iran:
High Inflation and Falling Rial Value: Iran is experiencing high inflation and a falling rial value, which are worsening daily and having a significant impact on social media. Citizens are expressing concerns about the bad economic situation and the financial problems they face daily, with some protesting against the Islamic Republic.
Austerity for the People, Prosperity for the Government: Users claim that austerity measures are primarily affecting the people, while the government maintains prosperity and growth in its budget.
Rising Prices: The prices of everyday goods, such as tea, have become very expensive.
Salaries and Wages: There are discussions and criticisms regarding the salaries set for employees and retirees, with some users joking that the government should not “break its back” over these amounts. Some users emphasize that the set amount is not even enough to buy basic goods.
Workers’ Wage Determination Committee: A journalist noted the existence of the Workers’ Wage Determination Committee, which determines workers’ livelihoods annually. There is a sentiment that the salaries and wages are becoming less and less valuable over time.
Government Spending Priorities: Amidst the economic difficulties, criticisms are raised regarding the government’s budget allocations to various entities such as the prayer headquarters, the Iranian Broadcasting Corporation, the Islamic Propaganda Organization, and the Revival Headquarters, while employees and retirees receive what is considered a “shameful amount” under the pretext of a lack of budget.
Impact of US Sanctions on Oil Sales: The Trump administration’s policy of maximum pressure and aiming to reduce Iran’s oil revenues to zero has led to a decrease in Iran’s oil exports. International reports indicated a 40% decrease in Iran’s oil exports to China in January.
Discounts on Oil Sales: Due to sanctions, Iranian oil sales are subject to discounts, which has caused turmoil in the country’s economic situation. The fact that Iranian oil cannot follow its normal routine due to sanctions means it will be discounted, possibly more than before.
Destinations for Iranian Oil: The Islamic Republic is sending oil to small, private ports in China after major ports refused to deliver it due to US sanctions. However, these ports have limitations in terms of the volume of oil they can handle.
Circumventing Sanctions: There are reports of fraudulent activities at these private ports, such as changing licenses to sell the oil to the Chinese domestic market.
Financial Aspects of Oil Exports: The financial return to Iran from these oil exports has always been marginal, with China providing goods or other items through the Central Bank of China instead of cash.
Role of IRGC Commanders’ Children: Some children of IRGC commanders are allegedly involved in facilitating oil transfers through offices set up in countries like Malaysia, Indonesia, and the UAE.
Overall Economic Pressure: The issues surrounding oil sales are adding to the pressure on Iran’s economy.
Iran: Economic Crisis Under Sanctions
The sources discuss the economic conditions in Iran, highlighting the impact of sanctions, inflation, and governmental policies on the populace.
Key points on Iran’s economic conditions:
Inflation and Currency Depreciation: Iran faces high inflation and a devaluing rial, leading to widespread concern and discontent.
Austerity Measures: Citizens report that austerity measures disproportionately affect the people, while the government maintains a prosperous budget.
Rising Costs: The prices of essential goods like tea have become prohibitively expensive.
Wage Issues: There’s criticism concerning the insufficient salaries for employees and retirees. The Workers’ Wage Determination Committee is seen as ineffectual, with wages decreasing in value over time.
Government Spending: Critics point out the government’s allocation of funds to entities like prayer headquarters and broadcasting corporations, contrasting it with the “shameful amount” allocated to employees and retirees.
Impact of US Sanctions on Oil Sales: The Trump administration’s “maximum pressure” policy aimed at reducing Iran’s oil revenues has resulted in a decline in oil exports. January saw a reported 40% decrease in oil exports to China.
Oil Sale Discounts: Due to sanctions, Iranian oil sales are subject to discounts, causing economic disruption. The restrictions prevent normal oil sales and lead to further discounting.
Oil Destinations: Iran is using small, private ports in China to circumvent sanctions after major ports declined to handle Iranian oil. However, these ports have limited capacity.
Circumventing Sanctions: Reports suggest fraudulent activities at these private ports, like altering licenses to sell oil domestically in China.
Oil Export Finances: The financial returns from oil exports are marginal, with China often providing goods instead of cash via its central bank.
Role of IRGC: Individuals connected to the Islamic Revolutionary Guard Corps (IRGC) are allegedly involved in managing oil transfers through entities in countries such as Malaysia, Indonesia, and the UAE.
Economic Pressure: The oil sales situation is compounding the pressure on Iran’s economy.
Human Rights in Iran: Voices and Struggles
The sources discuss human rights in Iran, particularly in the context of the Iranian government’s actions and the efforts of activists and political figures to address these issues.
Key aspects of the human rights situation in Iran, as highlighted in the sources:
Suppression of Protests: There is mention of the suppression of protests in Iran and the situation of political prisoners. Prince Reza Pahlavi, along with other Iranian activists, spoke about the suppression of protests, the situation of political prisoners, and the future of democracy in Iran at the Geneva Summit.
Human Rights Violations: The summit in Geneva coincided with the United Nations Human Rights Council and was held to examine human rights violations and people’s struggles for freedom and democracy.
Prince Reza Pahlavi’s Speech: Prince Reza Pahlavi addressed the UN Human Rights Council in Geneva, stating that the time has come to take action to destroy the Islamic Republic. He emphasized that the Iranian people are fighting for freedom, justice, and human dignity. He also stated that the Iranian people are not asking for sympathy but for partnership in their struggle.
Role of Iranian Activists: Iranian activists abroad are working to be the voice of the Iranian people and to address the oppression of their compatriots.
Summit for Human Rights and Democracy: The Geneva Summit is for human rights and democracy and includes activists, political figures, and victims of repression from around the world.
Garik Kasparov’s Speech: Chess player and political activist Garik Kasparov spoke about the unity of human rights activists around the world against dictatorships. He emphasized the need to unite efforts to fight dictators.
Empty Chair for Ahmad Reza Jalali: An empty chair was dedicated to the memory of Ahmad Reza Jalali, a dual-citizen prisoner in the prisons of the Islamic Republic of Iran.
Charter of Human Rights: There is a reference to Cyrus the Great’s Charter of Human Rights and the hope that it will return to Iranian soil. The focus was on the return of human rights to Iran, with emphasis on the freedoms of Iranian girls and women and the plight of fathers in prison and children who have lost their lives.
Panel on Brutal Treatment of Protesters: A panel was held on the Islamic Republic’s brutal treatment of protesters, moderated by Nazanin Afshin Jam.
اخبار شبانگاهی، سهشنبه ۳۰ بهمن
The Original Text
Hello, good time, viewers of Iran International from the London studio. You are Tel Naz Khameh. Headlines. Those who want to shut us down or stand in our way, I tell them, we will not ask for your green light. We will not wait for your green light. Speech by Prince Reza Pahlavi at the UN Human Rights Council in Geneva. Prince Reza Pahlavi says that the time has come to take action to destroy the Islamic Republic. The end of the first round of US- Russia talks on ending the war in Ukraine. Marco Rubio announced the decision of Washington and Moscow to normalize relations between the two countries. In the appendix, we look at previous meetings between the leaders of Russia and the US. Previous meetings of Putin and Trump and the achievements they had. Of course, whenever our oil is under sanctions and it cannot follow its normal routine, it will definitely be discounted. A member of parliament’s account of the extensive discount on oil sales was also reported by Bloomberg News. Following US sanctions, the Islamic Republic sends oil to small Chinese ports. Reflecting the high inflation and the collapse of the rial, users say that austerity is for the people, and prosperity and growth Budget for the government Also in this news section, Esteghlal’s fateful confrontation with Qatar’s Ryan in the Asian Elite League, only one team from the Reds, Saudi Arabia, is playing. Welcome to the Geneva Summit today. We see live images from this summit. This summit for human rights and democracy is being held today with the presence of activists, political figures, and victims of repression from all over the world. This summit, which coincides with the United Nations Human Rights Council, examines human rights violations and people’s struggles for freedom and democracy. Prince Reza Pahlavi was one of the main speakers at this summit and, along with other Iranian activists, spoke about the suppression of protests, the suppression of protests, the situation of political prisoners, and the future of democracy in Iran. We will see together that these are all consequences of a regime that plunders its own country instead of governing it. But whatever the Islamic Republic has created will only disappear with the destruction and overthrow of this regime. Today, we have a historic opportunity. The regime is more corrupt than ever. Its axis of resistance has been dismantled and its internal legitimacy has been destroyed. Now is the time to act. The Iranian people are not only fighting for themselves, but for the values of freedom, justice, and They are fighting for human dignity. This is not just a matter of the survival of my nation. It is also a matter of global stability and global peace. Because, as we witnessed this past week, from terrorist attacks to hostage-taking, the Islamic Republic, despite its lip service in Davos and its demand for a new agreement, is still seeking war with the world and will not stop until it is overthrown. I have been traveling in Europe for the past two weeks and have spoken with government leaders. I know from various parties that Iranians and their democratic ideals have many friends in Europe and the world. But I tell those who want to silence us or stand in our way, we will not ask for your green light. We will not wait for your green light. The Iranian people are not asking for your sympathy. They are asking for your partnership. Our question is, will you stand with us? Thank you. Farnoush Tabatabaei, an activist of the Islamic Revolution, says about the impact of the Geneva conference on the struggles of the Iranian people. In these 46 years, the people have suffered oppression and lacked political freedom. But today, Iranians abroad can hear the voice of the Iranian people speaking with unity. It is from Iran and oppression of our compatriots is our national and patriotic duty, as the leader of our national movement, Reza Shah II, declared and we elected him. For this leadership, we know it is our duty to always and everywhere be present where human rights and the rights of the Iranian people are discussed and try to be the voice of the silent ones. Look, Mr. Abbassian, I have been forced to emigrate for many years because of what happened in Iran in 1979. I lost my homeland, I lost my people, I lost my culture, but I tried to carry all these things in my heart with me until the day when we return the leader of our national movement to Iran, we will return our own life to Iran. And of course, these movements, although we still have shortcomings and shortcomings, we must practice democracy. We must respect all the movements that are active and the only way to save Iran is unity under the leadership of Reza Shah II. We will join my colleague Mehran Abbassian from the meeting in Geneva. Mehran is The 17th round of this summit, tell us more about the programs of this period. First, the Tenz actually had two parts. The morning part and the afternoon part. The morning part began with a speech by Garik Kasparov, a chess player and political activist who opposed the Putin regime. Garik Kasparov mostly talked about the unity of human rights activists around the world against dictatorships. He said that we should put the tests together so that we can better fight dictators. In the morning part, an empty chair was dedicated to the memory of Ahmad Reza Jalali. His name was mentioned as a dual-citizen prisoner in the prisons of the Islamic Republic of Iran. The afternoon part was dedicated to Iran. You broadcast the speech of Prince Reza Pahlavi. The name of this speech was “Fight for the Freedom of Iran.” Most of those who came to the Tenz hall were Iranians who came from all over the world to support the movements in Iran and Prince Reza Pahlavi in Geneva. Many did not find the opportunity to go inside the hall because more Iranians had actually come here than the hall could accommodate. Many were taken to the side halls. That they can see there by video conference. Well, now the voices that you hear inside the lobby, actually outside the main hall, Iranians have found each other and are actually engaged in political discussions. They are talking about the women’s movement, you have given them a free life, and there is Mr. Babak Karim Khan Zand next to me on other issues. I want to point out this, Mr. Babak, were you in the hall? What was new in Prince Reza Pahlavi’s speech? And how much do you think such a meeting can bring the people of Iran to a democracy and human rights? Peace be upon you. The beauty of this meeting today was that it was not about politics, it was about the return of human rights to our homeland. 2,500 years ago, Cyrus the Great wrote the Charter of Human Rights, and today we are witnessing that the Charter of Cyrus and human rights are going to return to Iranian soil again. We all heard the prince’s speech. Everyone cried because he spoke from the hearts of his people. Today, it was not about who or what kind of government is going to be established in Iran. Rather, the voices of the Iranian people were going to be heard today from the hearts of the people. He spoke about the freedoms of Iranian girls and women. He spoke about freedom and They told of the torture of fathers who are in prison today, children who lost their lives, and we saw these tears in the eyes of non-Iranians who realized what is happening in our homeland today. Our conversation is not about politics, today is about the heart, love, and freedom that we hope will return to our homeland soon. The beautiful message of the prince, because today is the time for action, was very beautiful. Be very brief. In part of their conversation, they referred to the unity that emerged between the Iranian people and the Iranian protesters in the Women’s Uprising for Freedom. Do you think such a unity will emerge between different political spectrums to hold rallies outside Iran? I don’t know about outside the country, but I know that inside Iran, people’s hearts are with all people. Those outside Iran whose hearts truly beat for the Iranian people and for the liberation of the Iranian soil must have this duty to sit together. Maybe you and I have different opinions, but we shake hands, kiss, and say that we are happy to see you. I hope so. Political parties should also reach this conclusion. In order to reach and return to Iranian soil, we need to be together. Thank you very much. Well, there is only one panel being held right now. It is called the Islamic Republic’s brutal treatment of protesters. Nazanin Afshin Jam is the moderator of this panel. Five of those affected by the Yazidi Women’s Uprising are participating in this panel. Thank you for Mehran Abbassian’s report from the meeting in Geneva and also for the guests we had. US and Russian officials concluded the Ukrainian peace talks in Saudi Arabia, which began this morning. Russian Foreign Minister Sergei Lavrov and Vladimir Putin’s aide arrived in Riyadh yesterday to conduct these talks. US Secretary of State Marco Rubio and Steve Jobs, Trump’s special envoy for the Middle East, are also representatives of the US government who traveled to the Saudi capital to conduct these talks. The talks between senior US and Russian officials in Riyadh, the capital of Saudi Arabia, ended while the Russian presidential aide said that the talks on the Ukrainian issue would begin at the appropriate time and with Vladimir Putin’s decision. He pointed out the need The US-Russia cooperation said that separate teams of negotiators are ready for this issue, but it is difficult to set a specific date for the leaders of the two countries to meet. We will join my colleague Niloufar Pour- Ebrahim from Paris. Niloufar, the Riyadh talks have ended. Tell us more about what was mentioned in these talks. We can say that in general, these talks were more than related to Ukraine itself, an opportunity for the two sides to talk, Russia and the United States, to improve their relations. For example, one of the most important things that they say is the way to emphasize and reach an agreement is to resume bilateral relations and in this context, the consulates of both countries should be opened. We know that in recent years, for various reasons, diplomats from both sides have actually either recalled or expelled their diplomats from the country. For example, the United States expelled Russian diplomats and then the United States diplomats were expelled from Russia. So one of the most important things is this. And then the discussion related to the Ukraine talks is that Volodymyr Zelensky from He has strongly criticized Vladimir Zelensky, who is currently in Turkey and is meeting with Erdogan, and has indicated that he will not accept talks on Ukraine that do not involve Ukrainians, as well as his trip to Saudi Arabia, which was scheduled to take place tomorrow. In addition, two teams are to be formed from the United States and Russia to advance future negotiations. US Secretary of State Marco Rubio has indicated that the discussion of territory and security guarantees will be among the important issues of future talks on peace in Ukraine. He has indicated that their discussion is not a short stop, but rather a search for lasting peace, something that European countries have expressed concern about. On the other hand, the US team was asked about the role of European countries. Regarding the criticism that they were sidelined, the White House National Security Advisor pointed out that they were not sidelined, that they are constantly consulting and discussing with European officials. He referred to Donald Trump’s conversation yesterday and said that these talks are like the shuttle diplomacy talks or The round-trip talks that are held in different places, but he did not mention the fact that usually in the diplomacy shuttle, both negotiating groups are present in the same region. Ukraine is not present here. Another issue that I talked about, Marco Rubio mentioned that European countries will join these talks at some point. They must join because the sanctions must be lifted. Some of these sanctions were imposed by the Europeans. Lavrov also mentioned various issues, including that Russia will not and will not accept that European forces will be present in Ukraine under any flag. Thank you for your explanation, Niloufar Pour-Ebrahim, my colleague from Paris. While you were talking, we were still seeing live images of the speech of Vladimir Zelensky, who had a meeting with Erdogan. We will continue this discussion with Rajab Safou, the director of the Center for Contemporary Iranian Studies in Russia. Mr. Safou. Do you think this meeting will cause a change in Russian-American relations? Look, the whole world now thinks that this important issue that is currently in the world, the issue of Ukraine, is really part of the main cooperation program or The talks between Russia and the US are fine, but in principle, the US and Russia have reached a point where they must have these talks, and these talks are essentially an excuse for Ukraine. It is true that it is an important issue, but relations and the resumption of relations between the two countries are the most important agenda of this meeting. This meeting, which ended in Saudi Arabia, is preparing the ground for Mr. Putin’s meeting with Mr. Trump, which is a very important development in itself. Certainly, what is happening now is a very important area, a very important event in the international community, because the fate of the international community and the issue of global political escalation really depends on the US and Russia. So what happened in Riyadh is the first step, but this issue is so complicated. The second issue, which is Ukraine, is so complicated that it really cannot be said that it has come to a conclusion now. The important thing is that the dialogue, that is, the US-Russia dialogue, began, and this was the last straw when they were approaching confrontation and war. Mr. Trump felt that he had to do something immediately to prevent the issue of war. Because if this continues, after a few more years, Russia will win. The European Union will be completely destroyed. Therefore, what is very clear is that Mr. Trump understood that if he does not intervene now, he will lose Europe, the Middle East, the entire world, and the dollar itself in the international settlement. Therefore, he came to the fore very, very quickly to prevent this from happening. He did not even look at the European Union and Ukraine, and the rival he had in the international community, which for three years was almost the main rival, today can be a partner in the US strategy in resolving and establishing stability in the international community. How likely is it that these negotiations will help end the war between Ukraine and Russia? I do not think that this war, at least the first part, the main part, the warm part, as they say, can be ended with one voice and one speech, because it can really be said that the European Union has its own interests here. The European Union is not willing to end the war in any way, because if they end this war now, this is the loss of all of Europe, the West, and the Western world. And America will be the master. So the Western world, with America as its master, has spent more than a trillion dollars here and wants to really beat Russia and shut it up. But if this continues and the war ends, this is a declaration of victory for Russia, which can change the fate of today’s political actors, destroy the European Union, lower its influence, because the European Union can’t do anything right now to solve the Ukraine issue. So what is the message of these negotiations for the Islamic Republic, which is not willing to negotiate with America now? See, this is a clear example that we need to negotiate. We need to have face-to-face policies. In any case, they can be successful to some extent and talk about the independence of countries and allow countries to prepare themselves for greater resistance or for the future war. But in the matter of fact, in today’s global political composition, leaders should come to the fore who are ready to negotiate, to be ready to negotiate, to at least some extent, to protect the interests of other countries. Tolerating and tolerating some things, I don’t know how far Mr. Putin can tolerate some of himself turning things to the West, but as far as I know, if it is possible, Russia’s interests will be preserved to the end, both for Iran and for the Islamic Republic of Iran. The fact that this scene that is taking place in Riyadh now, and perhaps the meeting will bring Mr. Putin and Mr. Trump, is a good thing. Excuse me, Mr. Ambassadors. Time is up. Thank you for your presence. Rajab Safarov, Director of the Center for Contemporary Iran Studies in Russia. One of the goals of the secret talks is to pave the way for a possible meeting between Vladimir Putin and Donald Trump to discuss the Ukraine issue. This will not be the first time that the presidents of Russia and the United States have met. In today’s episode, Berdia Afshin looks at previous meetings between Putin and Trump and their [musical] results. Before Donald Trump entered the political arena, long before he became president, he was interested in investing in Russia since the late 1980s. Trump’s relationship with Russia is very complex and very controversial, but let’s look at the relationship between the US president and the US president. Donald Trump’s relationship with Vladimir Putin, a man who has held power in Russia for more than a century, is not easy to analyze. These images are from the last face-to- face meeting between Trump and Putin in 2019, on the sidelines of the G20 summit in Osaka, Japan, during Trump’s first term as president. Since then, many things have changed, including Russia’s invasion of Ukraine and the tense relationship between Moscow and Washington that has become much darker than before. However, the relationship between the two men has not been as cold as the Russian-American relationship. At times, it has even been very personal and very sincere. Before Donald Trump came to power in the United States, Vladimir Putin had called the American leader a “[ __ ],” a man who, according to Putin, was passionate and a very talented man. Trump also said that he was honored to be praised in this way by someone who is highly respected in his own country and abroad. He said that Putin. During the 2016 election campaign, Trump repeatedly brought up Vladimir Putin and called him a strong leader, which had caused many concerns in the United States because They see Putin as an autocratic leader and say that Donald Trump ignored this. Of course, Trump said that the United States could have better relations with Russia under his leadership. Following Donald Trump’s victory in the 2016 US presidential election and his Democratic rival Hillary Clinton, US intelligence agencies announced that Russia had carried out an organized cyber operation to influence the outcome of the election in Trump’s favor. Interestingly, since then, Trump has not only always denied this, but has repeatedly said that he believes Putin, not US security officials, that Putin said he did not do this. So let’s look at the meetings between the two, which have repeatedly mentioned this issue. Trump and Putin met for the first time on the sidelines of the G20 summit in Hamburg, Germany in 2017. It was an opportunity to talk about issues such as Syria and Ukraine. After the two-hour meeting, Trump told him that he should give him the interpreter’s notes and ordered the interpreter not to reveal what he had heard to anyone. Later that night, at a dinner party, Trump sat next to Putin’s chair to talk to him. There were no American witnesses with Trump, which made many in the United States wonder what Trump was talking about with Putin. That same year, in 2017, at the Asia-Pacific Economic Cooperation summit in Vietnam, the two men had another chance to meet. It wasn’t an official bilateral meeting, but during the summit in Vietnam, they had a brief conversation. At the end of the meeting, they issued a joint statement on Syria, which emphasized the two countries’ commitment to defeating ISIS. Despite the widespread tensions between Washington and Moscow, the statement was important and showed that the two countries wanted to take joint action in areas of cooperation. But the images we saw were from the first official bilateral meeting between Vladimir Putin and Donald Trump in July 2018 in Helsinki, the capital of Norway. A high-profile meeting that attracted global attention was highly controversial. During the Helsinki summit, Trump and Putin held a private one-on-one meeting, attended only by interpreters. And then, after holding a joint press conference like this, Trump said after the meeting that Moscow-Washington relations had never been this bad before. However, Trump believed that he really believed that during this 4-hour meeting, the state of Moscow-Washington relations had changed. As I said, this meeting was very controversial in 2018 because Trump again seemed to agree with Putin and deny Russian interference in the 2016 US presidential election, a claim that contradicted the findings of US intelligence forces. In November 2018, the White House announced that then-US President Donald Trump would not hold a previously planned meeting with Vladimir Putin on the sidelines of the G20 summit in Buenos Aires and that the meeting would not take place. Trump, who was dissatisfied with Russia’s actions in Ukraine, had canceled the meeting because he had made this decision while the Kremlin had still announced Putin’s readiness for this meeting and emphasized it. However, at the G20 summit in Osaka, Japan the following year, the leaders’ meeting on the sidelines of the summit in As we saw earlier, they met on the sidelines of the summit and discussed issues including Iran, Syria, Venezuela, and Ukraine. Of course, this meeting did not lead to any significant political change. However, despite personal admiration for Putin and the fact that at the 2019 G7 summit, Donald Trump officially called for Russia to be re-admitted to the G7 so that it would once again become the G8, the Trump administration imposed extensive sanctions on Russia due to Russia’s interference in the elections of other countries, including the United States, as well as the poisoning and assassination of their opponents. Although Trump’s critics say that the then US president was hesitant to implement these sanctions, as the 2020 US presidential election approached, Vladimir Putin distanced himself from Trump and accepted the possibility of his opponent Joe Biden winning. Putin told him that the men of Moscow would accept and work with any leader the American people elect. Of course, Putin even called Trump’s accusations against Biden that Joe Biden was pro-Russian completely unfounded. It goes without saying that during the time when Trump was not president, when Joe Biden was president, It seems that Trump has not cut off his contact with Putin. In this book, the famous journalist Bob Woodward’s new book titled War, it is mentioned that Trump may have made private calls with Putin several times during this period. This revelation could be interesting in that despite the many tensions between the United States and Russia, Trump has maintained this connection, maintained his interaction with world leaders, and perhaps his goal was to return to power. These images that we saw were of Donald Trump’s first phone call with Vladimir Putin during his first term as president. Now at least we know that these two men talked on the phone for 90 minutes during Donald Trump’s second term as president, and the possibility of their meeting is greater than ever. What will be the result of the closer relationship between the presidents of Russia and the United States? Will tensions decrease or will there be a change in this current tense situation? Which one determines the time? [Music] Bruger textile workers protested against the city’s governor’s failure to pay their salaries and demands. The workers say they have not received their salaries and insurance for months, and the authorities have not responded to their demands so far. They didn’t give [Music] [Music] You are still watching Iran International. Let’s take a look at the headlines again. Prince Reza Pahlavi’s speech at the UN Human Rights Council in Geneva. Prince Reza Pahlavi says it’s time to take action to destroy the Islamic Republic. The first round of US-Russia talks on ending the war in Ukraine ends. Marco Rubio announced Washington and Moscow’s decision to normalize relations between the two countries. My colleague Neshin Khani is here in the studios to review the reactions of users on the wrong networks. This time, let’s talk about the high price. Tell us more. Please. All the people living in Iran are in a big economic predicament. They don’t know how much the money in their pockets is worth to them today. They are talking about everything. Let’s talk about the living and economic conditions. Let’s do a part of them together. [Music] Inflation and inflation and the fall in the value of the rial, which are getting worse and worse every day, have had a lot of reflection on social media, and many citizens are writing about the bad economic situation, the financial and living problems that they are facing every day. They are struggling, they are protesting against the Islamic Republic. Users say that the Islamic Republic is indifferent to the suffering of the Iranian people. A user wrote, “Everything you buy has become expensive. God forbid. The price of a kilo of tea is 800,000 tomans.” He criticized the government and asked, “What’s the matter with you? Where are we going? You still don’t want to give up your illusions?” Another user criticized the authorities’ language, referring to severe inflation, and said that it seems that if instead of “expensive,” they said the problems would be solved. He continued that he wished they were as serious about reforming the economy as they were about changing the language. He emphasized that people’s tables will not be filled by changing new words. Ashkan reported on the living conditions and reported that you have to give up two months’ salary to put some meat in the freezer, especially if you bought the freezer before the sanctions and have had a house with a freezer in it. The author of this post says that people are spending money on meat and fish, but the government is not willing to spend money on the Iranian Broadcasting Corporation and seminaries. He believes that economic austerity is only for the people, but wasteful spending is for the government. But one Among the issues that many users are talking about is the amount of the salary set for the employees of the director and retirees. Ali Mizan wrote this salary and joked that the government should not break its back. At one time, he emphasized that this amount of money is not even enough to buy Eid fruits. A journalist wrote that we also have something called the Workers’ Wage Determination Committee, which every year during the Sabbath, the workers’ livelihood is determined. They consider one-fifth of whatever amount is made as the workers’ salary. This user recalled that years ago, salaries were given to each worker and employee equal to one month’s salary and continued that now the looters sitting on the treasury are slowly changing it, and every year salaries and salaries become less and less valuable. Of course, he wrote, “Shame on you.” Finally, this user wrote this reaction: While the government of the doctors has set the salary of employees and retirees at a shameful amount of 3 million tomans under the pretext of a lack of budget, the budget for the prayer headquarters is 330, the budget for the Iranian Broadcasting Corporation is 33, the Islamic Propaganda Organization is 28, and the Revival Headquarters is 24. The price of oil increased by 19, and I will continue to return to my colleague Tanaz. Thank you for your reading, my colleague. Here, with the announcement of the Trump administration’s policy of maximum pressure on the Islamic Republic and zeroing out Iran’s oil revenues, international reports indicate a 40% decrease in Iran’s oil exports to China in January. Mohammad Bahrami, a member of the Parliament’s Energy Commission, also emphasized the continuation of discounts for oil sales and said that the situation of oil sales has caused turmoil in the country’s economic situation. Certainly, whenever our oil is under sanctions and it cannot follow its normal routine, it will definitely be discounted, meaning that it will definitely be discounted more than it has been discounted so far. I don’t think so. I don’t think so, but like the previous routine, it will definitely be discounted. Well, don’t you think that this situation will put much more pressure on our economy than this. It will definitely affect it. After all, the psychological atmosphere it creates will affect us for a while. We will see that our conditions are not good for a long time, and our economic conditions are not good. They will affect it, and some domestic brokers will also double this pressure with special programs. In this regard, Bloomberg News reported in a report. He mentioned private terminals in some small Chinese ports as new destinations for oil purchased from Iran and Russia. According to this report, after China’s major ports refused to deliver Iranian and Russian oil, private terminals in the country’s small ports became destinations for sanctioned tankers. In this regard, we will join Mehdi Mozambi, an oil market expert from London. Mr. Mozambi, what is your assessment of these international reports about the decline in Iranian oil exports and especially the status of oil exports to China? Greetings to you and the viewers of this program. The first thing I can say is that this shows that you see that both Benberg reported this and Reuters both mentioned these news agencies. In addition, several news outlets or news sites, such as Energy Connect or First Price, have regularly made phone calls to the Schengen customs officials around China and asked to ask about this. This shows that in no way are these oil transfers out of sight and out of mind, and in any case, several different forums are looking at these. Well, from This idea ties the hands of the Chinese so that they can bypass the sanctions under their noses or somehow get around them. But the point is that these ports, as your report also said, are small ports. They are private ports. What they can do is that they cannot handle more than 700,000 to 800,000 barrels of oil per day. That is, they cannot handle such tankers. That is why there is some limitation. For the larger tankers that the Islamic Republic usually used, you see, these tankers are about 43 tankers that are under US sanctions. They cannot dock in regular Chinese ports or anywhere else. They cannot dock and are limited to these private ports. What they can do there is to change these licenses, that is, to do some fraud and write something new there and sell it to the Chinese domestic market as private ports. It can be said that they are doing the same thing that was done in Malaysia and the UAE before, bringing it into China, which somehow lowers the price for them. The financial part of oil exports by the Islamic Republic has always been marginal. How much money from oil exports actually returns to Iran? If we briefly look at it later, you can see what is happening. As I said earlier, some of the children of these IRGC commanders, like Shamkhani’s son, had set up offices in Malaysia, Indonesia, and the UAE. I think there was a certain amount of cooperation that was in our country. Their job was to come and go around and even go to places and transfer tankers to tankers. In any case, they would bring it down. Now, bringing it down lower. And you know that China does not give cash to Iran. Now, it will definitely give it to Russia, but it will not give it to Iran. And it does this through the Central Bank of China in the form of Chinese goods or other issues. They are giving it to Iran, and as a result, cash money will not be returned to Iran. Thank you for your explanations. Mehdi Moslehi, oil market expert from London. We have reached the end of this news section. Thank you for your support. This is my colleague Aydin.
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
Navigating Dating Myths: A Deeper Understanding of Relationship Realities
The labyrinth of modern dating is often clouded by well-intentioned yet misleading clichés that promise simplicity in the complex realm of love. These myths, though comforting, can obscure the nuanced realities of building meaningful connections. By dissecting five prevalent misconceptions, we can foster healthier, more intentional relationships grounded in authenticity rather than fantasy.
Misconception 1: Love Alone Sustains a Relationship While love is a cornerstone of romantic partnerships, it cannot single-handedly resolve fundamental incompatibilities. Relationships thrive on shared values, mutual goals, and emotional alignment. For instance, two individuals may deeply care for one another but find themselves at odds over core life choices, such as marriage, career ambitions, or lifestyle preferences. These divergences, if unaddressed, create fissures that affection alone cannot mend. Love must coexist with practical collaboration to navigate challenges and sustain long-term harmony.
Equally critical is recognizing when love becomes a catalyst for self-betrayal. Sacrificing personal boundaries or core values to preserve a relationship often breeds resentment. Over time, partners may contort themselves into roles that feel inauthentic, eroding the connection they once cherished. A relationship rooted in enduring respect and compatibility—not just passion—allows both individuals to grow without losing themselves. Acknowledging this balance helps couples prioritize holistic health over fleeting romantic idealism.
Misconception 2: Love Inspires Fundamental Change The belief that love can transform a partner’s inherent traits is a recipe for disillusionment. While small compromises are natural, expecting someone to overhaul their personality or habits for the sake of romance ignores the reality of human nature. For example, a chronically disorganized individual may improve punctuality with support, but a fundamental shift in temperament requires internal motivation, not external pressure. True change arises from self-awareness, not coercion.
Moreover, fixating on a partner’s “potential” risks devaluing their present self. Relationships strained by constant criticism often spiral into resentment, as the criticized partner feels unaccepted. Conversely, fostering a safe space for mutual growth—where flaws are acknowledged without judgment—can organically inspire positive evolution. Embracing authenticity over idealized versions of each other nurtures a bond built on trust rather than conditional approval.
Misconception 3: Breakups Happen Without Warning Most relationship endings are the culmination of unresolved issues rather than sudden whims. Subtle signs, like dwindling communication or recurring arguments, often signal underlying discontent. Partners may dismiss minor conflicts—such as disagreements over finances or emotional distance—until these patterns solidify into irreparable rifts. Prolonged neglect of such issues creates a chasm that even earnest efforts may struggle to bridge.
Research underscores the predictability of relational breakdowns. The Gottman Institute’s identification of the “Four Horsemen”—criticism, contempt, defensiveness, and stonewalling—highlights how toxic communication styles corrode intimacy. Couples who habitually employ these tactics during disputes often find their connection irreversibly damaged. Recognizing these patterns early allows partners to address conflicts constructively, potentially averting a breakdown. Hindsight often reveals that the seeds of a breakup were sown long before the final farewell.
Misconception 4: Breakups Require a Villain Labeling one partner as the “bad guy” oversimplifies the intricate dynamics of failed relationships. While some situations involve clear misconduct, most splits stem from mismatched needs or mutual misunderstandings. For instance, one partner may prioritize career over romance, not out of malice, but misaligned priorities. Framing such scenarios as black-and-white moral failures stifles personal growth and accountability.
Reflecting on shared responsibility fosters emotional maturity. Examining why certain traits initially attracted us—such as a free-spirited partner later deemed unreliable—reveals patterns in our choices. This introspection, free from self-blame, empowers individuals to make wiser decisions in future relationships. By releasing the need for villainy, we embrace the complexity of human connections and cultivate empathy, both for ourselves and others.
Misconception 5: Faded Passion Signals Relationship Death The transition from fiery romance to steady companionship is often mistaken for emotional decay. Long-term relationships inevitably ebb and flow, with passion waxing and waning due to life’s demands—parenthood, career stress, or health challenges. A couple might find date nights scarce but discover deeper intimacy through shared responsibilities, like co-parenting or managing a household. This evolution reflects natural progression, not failure.
Revitalizing connection requires intentional effort. Engaging in novel experiences, practicing gratitude, or prioritizing quality time can reignite sparks. For example, planning spontaneous getaways or revisiting shared hobbies fosters renewed appreciation. Embracing the relationship’s evolving nature—rather than clinging to its initial intensity—allows love to mature into a resilient, enduring bond.
Conclusion Dispelling dating myths invites a shift from rigid expectations to adaptive understanding. Relationships demand patience, self-awareness, and a willingness to embrace complexity. By rejecting oversimplified narratives, individuals can navigate love’s challenges with clarity, fostering connections that are not only passionate but purposeful and enduring.
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
This lecture by a senior curriculum manager at Codesmith covers large language models (LLMs), explaining their underlying mechanisms, such as tokenization and the self-attention mechanism in transformer architectures. The lecture details the training process, including pre-training and fine-tuning, and emphasizes the importance of prompting as a crucial skill for effectively utilizing LLMs. Various prompting strategies are discussed, along with methods for evaluating LLM outputs and mitigating risks associated with their deployment. Finally, the lecture explores the future of prompting and the challenges of maintaining LLM applications while keeping costs low.
Large Language Model Study Guide
Quiz
Instructions: Answer the following questions in 2-3 sentences each.
Why is data quality significant in training Large Language Models (LLMs)?
Briefly describe the “AI winter” and its impact on AI research.
How does AlphaGo version 2.0 differ from version 1.0, and what is the significance of this difference?
Explain the importance of tokenization in the context of LLMs.
What are embeddings, and how are they used to represent words in a mathematical space?
How does the self-attention mechanism allow LLMs to understand the context of a sentence?
Describe the process of self-supervised learning in pre-training an LLM.
What is a base model, and how does it differ from a fine-tuned LLM?
What does it mean to say LLMs are like playing a word association game?
What is the purpose of a “ground truth data set” when evaluating a model’s output?
Quiz Answer Key
Data is critical because the quality and biases within the data significantly impact the LLM’s performance and can lead to skewed or biased outcomes. Training data sets are massive and, therefore, even subtle biases are amplified within a model.
The “AI winter” refers to a period in the 1970s and 80s when enthusiasm for AI waned due to early promises not being met. This led to the splintering of AI into smaller subfields like machine learning, computer vision, and natural language processing.
AlphaGo 1.0 was trained by imitating human play, whereas version 2.0 was allowed to play millions of games in a sandbox environment with a reward function for winning. This allowed it to surpass human-level play, unconstrained by imitation.
Tokenization is the process of breaking down text into smaller units (tokens) for LLMs to understand. This process allows the model to work with linguistic meaningful units for processing and analyzing text data.
Embeddings are stored as vectors or arrays that represent the meaning of words in a mathematical space. Similar words, used in similar contexts, have similar embeddings which allows the model to understand semantic relationships.
The self-attention mechanism enables LLMs to analyze the relevance of each word in a sentence to other words in that sentence. This contextual understanding allows the model to interpret the meaning of words based on their context within a sentence.
Self-supervised learning allows models to use the data itself to generate the labels for training, for example by using the next word in a sequence as its label. This removes the need for time-consuming manual labeling, allowing much larger data sets to be used.
A base model (or foundation model) is a result of the pre-training process that can generate documents based on text input but isn’t capable of tasks such as question answering. Fine-tuning a model adapts it for a specific task, enhancing its performance in those areas.
The word association game analogy implies that LLMs respond instinctively based on patterns in their training data rather than understanding the underlying concepts. It is a simplification of the process, but the model is more or less just predicting the next word, given its input.
A “ground truth data set” is a collection of known inputs and their corresponding outputs which is used to evaluate an LLM’s performance. This allows developers to test the model and ensure that it provides the expected results.
Essay Questions
Discuss the evolution of AI, highlighting the key breakthroughs and challenges that have led to the development of Large Language Models (LLMs). Consider the impact of “AI winters” and subsequent technological advancements.
Explain the concepts of tokenization and embeddings, and analyze their critical roles in enabling an LLM to process and interpret textual data. Consider the nuances of tokenization such as subword splitting.
Compare and contrast the pre-training and fine-tuning processes of LLMs, highlighting the different purposes and methods involved. How does the shift towards self-supervised learning impact the scale and capability of current models?
Describe and evaluate different prompt engineering strategies, including the use of personas, Chain of Thought, few-shot learning, and structured outputs. Consider the trade-offs between computational complexity and effectiveness.
Analyze the ethical and societal considerations surrounding the use of LLMs, including concerns about bias, representation, environmental impact, and the potential for misuse. What measures can be taken to mitigate these risks?
Glossary of Key Terms
AI Winter: A period of reduced funding and interest in artificial intelligence research, usually due to unfulfilled early promises.
Base Model/Foundation Model: An LLM that has been pre-trained on a large amount of data but not fine-tuned for a specific task.
Back Propagation: An algorithm that allows a model to change internal weights based on its error rate.
Bite Pair Encoding: A method of tokenization that represents common words as a single token and breaks uncommon words down into subwords.
Chain of Thought: A prompting technique that encourages the model to break down a complex problem into intermediate steps before arriving at a final answer.
Constrained Decoding: A method used to specify the schema for JSON output by limiting the possible next tokens during generation.
Embeddings: Vector or array representations of words or tokens that capture their semantic meaning in a mathematical space.
Few-Shot Prompting: A technique where a prompt includes several examples of the desired input-output pairing to guide the model.
Fine-Tuning: Adapting a base model with additional training data for a specific task or domain.
Ground Truth Data Set: A set of input-output pairs used to evaluate the model’s performance.
Hallucination: When an LLM generates an output that is factually incorrect or not supported by its training data.
Instruction Tuning: Fine-tuning an LLM to respond well to instructions or prompts.
LLM (Large Language Model): A type of AI model trained on large amounts of text data capable of generating text, code, and other types of content.
Mechanistic Interpretability: The field of study that focuses on understanding the inner workings and processes of machine learning models.
Morphologically Rich Languages: Languages where the forms of words can change depending on their meaning in a sentence (e.g., Arabic, Turkish).
Parameters: The internal variables of the model that are adjusted during the training process.
Pre-Training: The initial training of a large language model on a massive dataset, focusing on learning general patterns and representations.
Prompt: The input given to an LLM to elicit a particular response.
Prompt Engineering: The process of designing and refining prompts to achieve the desired outcomes from LLMs.
RAG (Retrieval Augmented Generation): A technique that enhances LLM’s ability to access external knowledge bases during generation.
Self-Attention: A mechanism that enables an LLM to assess the relevance of different parts of an input when generating an output.
Self-Supervised Learning: A type of machine learning where the model generates its own labels from input data.
Stochastic Gradient Descent: An iterative optimization algorithm used to adjust model parameters to minimize error.
System 1/System 2 Thinking: A mental model that distinguishes between instinctive (System 1) and deliberate/rational (System 2) modes of thinking, according to Daniel Kahneman.
Tokenization: The process of breaking down text into smaller units (tokens) that can be processed by an LLM.
Vector Database: A type of database designed to store and efficiently retrieve embeddings or vector representations.
Zero-Shot Prompting: A technique where a prompt is given to a model without any prior examples.
Large Language Models and Embeddings
Okay, here is a detailed briefing document synthesizing the key themes and ideas from the provided text, complete with relevant quotes.
Briefing Document: Large Language Models (LLMs) and Embeddings
Introduction This document summarizes a presentation on Large Language Models (LLMs) and related concepts, focusing on how these models are built, how they work, and how they can be used effectively, especially through skillful prompting. The presentation emphasizes the role of software engineering principles in working with LLMs, highlighting both the challenges and the opportunities presented by this technology.
Key Themes and Concepts
Data is Paramount
The quality and biases of an LLM are directly determined by the data on which it’s trained.
LLMs are trained on “massive massive amounts of data” such as the entirety of English language Wikipedia (2.5 billion words) and a large book corpus (800 million words).
Quote: “the data is hugely significant in determining the quality and the biases of the model”
Evolution of AI
AI research started in the 1950s and 60s with initial optimism, followed by an “AI winter” in the 70s and 80s when that optimism faded.
This led to the splintering of AI into fields like machine learning, computer vision, and natural language processing.
The recent “rebirth of AI” is due to advances like AlexNet, AlphaGo, BERT, and ChatGPT.
Key to this latest wave is “self-improvement” models that learn by playing millions of games, not just imitating human players.
Quote: “In the past 10 to 15 years we’ve seen the Rebirth of AI as an umbrella field”
LLMs: Versatile and Accessible
Unlike specialized models trained for a single task, LLMs can perform many tasks well.
LLMs can be adapted to specific use cases, reducing the need for in-house ML teams.
LLMs have applications in natural language processing (text classification, translation, text generation, speech recognition, summarization, question answering), code generation, medical diagnosis, and more.
Quote: “…these large language model can do a lot of things very well”
Tokenization: The Foundation
Tokens, not words or characters, are the basic inputs for LLMs.
Tokenization splits text into linguistically or statistically meaningful units.
Spaces are included with the word tokens, and words are sometimes split into multiple tokens or subwords.
A tokenizer dictionary is fitted to the training data set to create the vocabulary for the model.
Quote: “tokens are the basic inputs for a large language model”
Embeddings: Representing Meaning
Embeddings are vector representations (arrays of numbers) that capture the meaning of words and tokens.
Similar words have similar embeddings, forming clusters in a multi-dimensional space.
Embeddings can be interpolated, such as combining “king,” “man,” and “woman” to get “queen”.
Embeddings can be used for semantic search, not just keyword-based search.
Quote: “an embedding is stored as a vector… it is not entirely possible as of now to understand what each number actually means to the model”
Attention Mechanism
The self-attention mechanism in the Transformer architecture allows models to determine the relevance of each word in a sentence to other words.
It enables understanding context by considering the relationship between words in a sentence, this is a groundbreaking element of the technology.
Each word stores three vectors: a value vector (meaning), a key vector (contextual meaning), and a query vector (input meaning).
Quote: “…the meaning of one word depends on the words around it”
Pre-Training and Document Generation
The pre-training process is about capturing the meaning of the data using large quantities of data, high end GPUs, and significant time investments.
Models are trained through self-supervised learning by predicting the next token in a sequence.
The result of pre-training is a base or foundation model that can only generate documents.
Quote: “the model essentially creates its own labels… the label is the following token”
Fine-Tuning for Specific Tasks
To adapt a base model for tasks like question answering, it must be fine-tuned with a smaller set of labeled data.
Fine-tuning can be instruction-based, iterative, or tailored to the last few layers of the model.
Quote: “we have to fine-tune it and we take the base model or Foundation model and we train it on a much smaller set of data”
Prompting: Programming with Natural Language
Prompting is the core skill for using LLMs, acting as the code used to guide models to produce desired outputs.
It’s a “subtractive” process, narrowing down the massive set of possible completions.
Prompts should be maintainable, readable, modular, and flexible, much like good code.
Prompting is an iterative process; a methodical process is essential for improvement.
Quote: “prompting is conditional generation meaning we are generating an output conditioned on some input”
Mental Models for LLMs
LLMs are not search engines, knowledge stores, or Stack Overflow in your editor.
They perform “system one” thinking: instinctive and automatic, akin to a word association game.
Framing LLMs in human thinking is misleading, but helpful until you form your own understanding.
Quote: “these models are not capable of system two thinking they are only capable of system one thinking”
Evaluating LLM Output
Key evaluation dimensions: grounding (assertions based on a reliable source), consistency (similar queries yielding similar results), confidence (acknowledging uncertainty), interpretability (why a response was generated), alignment (avoiding harm), and robustness (resisting manipulation).
Quote: “every assertion has authoritative basis”
Risks and Challenges
Lack of transparency around training data, potential for bias based on that training data.
Representation issues: internet data overrepresents certain demographics, and some models have been trained on content with particular biases.
Environmental costs and energy consumption of training large models must be considered.
Hallucinations are a built-in feature, not a bug, as the models are predictive engines, not knowledge stores.
Quote: “Hallucination is actually a feature it’s a feature it’s not a bug”
Software Engineering Opportunities
Many challenges in deploying LLMs are software engineering concerns, such as testing, version control, latency, maintainability, and monitoring.
LLMs can enhance productivity through automation and augment functionality, creating new, previously unfeasible products.
Quote: “These questions around testing and inversion control… are very much software engineering challenges”
Prompting Strategies
Key elements of a prompt: goal, role, and output format.
Use personae to invoke archetypes, process guidance to give step by step logic.
Use a “few shot” method by providing examples of desired input and output for the model to follow.
Delimiters and structured outputs are crucial.
Use techniques like “Let’s think step by step” and asking models to “check their work” to improve output.
Decompose complex problems into smaller sub-problems.
Employ ensembling (generating several responses and selecting the most common one) to improve accuracy.
Future Directions
The future of prompting is likely to involve a convergence between improved models and improved prompting techniques.
Use-case specific prompting will remain essential.
Multimodality and cross model versatility will become more important.
Conclusion Large Language Models are powerful and transformative tools with the ability to impact many fields. Understanding how they function, how to guide them with carefully crafted prompts, and how to integrate them using software engineering principles, are vital skills moving forward. While there are risks and challenges to be addressed, the opportunities presented by this technology are immense and exciting.
Large Language Models & Embeddings: A Comprehensive Guide
Large Language Models & Embeddings: An FAQ
What are Large Language Models (LLMs) and how do they work? LLMs are complex neural networks trained on massive datasets to understand and generate human-like text. They operate by first tokenizing input text (breaking it into smaller units), mapping these tokens to numeric IDs, and then using these IDs in mathematical operations to predict the next token in a sequence. This process allows them to learn complex relationships and patterns in the text, enabling them to generate new text, translate languages, and perform a wide variety of tasks. Crucially, this predictive ability is learned from the massive dataset provided in the pre-training phase, allowing the models to generate new data based on those learned patterns.
Why is data so critical in training LLMs, and what does the training process look like? The quality and quantity of data are paramount because the model learns its understanding of the world from it. For example, some of the first LLMs were trained on the entirety of English Wikipedia and large book corpora. The training process involves the model predicting the next token in a sequence over many rounds (epochs). The model is continuously adjusted using back propagation based on the difference between the predicted and actual tokens, eventually achieving an understanding of the patterns in the data. This training approach is also “self-supervised,” as the labels (i.e., the correct next token) are already part of the dataset, removing the need for manual labeling. This self-supervised technique allows the massive amounts of data to be used for training.
What are tokens and embeddings, and why are they important? Tokens are the basic units of input for LLMs. These aren’t always whole words; they can be sub-word units or punctuation with spacing included. This approach allows the model to capture the contextual meaning of the word by encoding the boundaries between words. Embeddings are vector representations of these tokens, where similar tokens used in similar contexts have similar embeddings. These embeddings encapsulate the model’s understanding of a word’s meaning, context, and relationships to other words. Embeddings are useful for semantic search where search is conducted based on meaning rather than keyword matches.
What is “self-attention,” and how does it help LLMs understand context? Self-attention is a mechanism in the Transformer architecture that allows LLMs to determine the relevance of every word in a sentence to every other word in that sentence. This is crucial for understanding the context of each word and resolving ambiguities, such as understanding which “it” is being referred to in a sentence like, “The dog chewed the bone because it was delicious.” The self-attention mechanism is able to associate the “it” with “bone” in that instance, whereas another similar sentence would likely associated “it” with “dog”. Self-attention allows models to consider the entire context of a sentence, rather than just the immediate neighboring words.
What is the difference between a “base model” and a model used in applications like chat? A “base” or “foundation” model is the output of the pre-training process. It can generate documents similar to those in its training data. It cannot answer questions or provide any kind of interactive experience. To adapt a base model for a specific purpose (e.g. question answering, acting as a helpful assistant), it needs to be “fine-tuned” or further adapted with a smaller set of labeled data relevant to the task at hand. This process adjusts the model’s parameters to be more responsive to a more specific domain and format of response.
What is “prompt engineering,” and why is it important? Prompt engineering is the art and science of crafting effective prompts to guide LLMs to produce the desired results. Since LLMs are conditional text generators, the quality of the generated text is heavily dependent on the prompt used. Effective prompts will not only produce results that meet the criteria you are looking for, but also will not introduce negative behavior in the model, such as hallucinations or toxic responses. Effective prompt engineering requires a software engineering mindset, emphasizing practices like clear intent, modularity, version control, and iteration.
What strategies can we use to make our prompts more effective? Several strategies can improve prompt effectiveness:
Clearly define the role, goal, and output format.
Provide instructions in a clear, itemized fashion.
Use delimiters to separate instructions, context, and data.
Set a persona for the model to emulate.
Provide examples of desired input/output patterns (Few-shot learning).
Guide the model’s reasoning process with “Let’s think step by step”.
Use Chain of Thought prompting where the model generates its reasoning steps in addition to its final output.
Use “cognitive verifier” prompts where the model asks clarifying questions of the user.
Give the model access to external tools like web search or code execution.
Use ensembling strategies by having the model generate many responses and choose the one most similar to the other generated responses.
Decompose the problem into smaller sub problems so the model can reason about each one individually. These approaches are rooted in making our implicit assumptions explicit to guide the LLM toward the intended behavior.
What are the key risks and challenges when working with LLMs, and what are some of the important opportunities in this field? Key risks and challenges include:
The lack of transparency around training data which introduces questions of bias, representation, and copyright
Model “hallucinations” or the generation of responses that are factually incorrect
The large carbon and financial footprint required to train these large models
The risk of models being exploited by malicious actors via prompt injections
Key opportunities include:
Automating tedious tasks and augmenting functionality by leveraging LLMs
Improving productivity through the automation of mundane work
Enhancing a range of products by making LLMs a core part of their functionality
Implementing new testing and version control systems specific to prompts and LLM interactions
Applying software engineering techniques to the development of prompts to improve their readability, flexibility, and maintainability
Large Language Models and Embeddings
Large language models (LLMs) and embeddings are key concepts in modern AI, and the sources provide a detailed look into how they work and how they are used [1, 2].
LLMs:
LLMs are complex models that learn from massive amounts of data [1].
One early LLM, Bert, was trained on the entirety of English Wikipedia (2.5 billion words) and an additional 800 million words from a book corpus [1].
The models need to understand text input and generate new text output based on the rules learned from the data [1].
LLMs can tackle tasks beyond natural language processing, including code generation and addressing challenges in engineering and medicine [3].
The basic inputs for an LLM are tokens, which are mapped to numeric IDs [3].
Tokenization is the process of breaking down text into smaller units [3]. The goal of tokenization is to have linguistically or statistically meaningful units [4].
Common words are represented by single tokens, and uncommon words are broken down into subwords, using byte pair encoding [4].
The tokenizer dictionary is fitted to the entire training dataset [4].
The vocabulary is the complete list of words that the model can understand [4].
The number of tokens a given input will be represented by is about 3/4 of the number of words [5].
LLMs do not distinguish between semantic knowledge and world knowledge, and they learn relationships between words [6].
They are pattern-learning machines that can predict the next token in a sequence [6, 7].
LLMs use key, query, and value vectors in their attention mechanism to understand the relationships between words in a sentence [6, 7].
Pre-training involves capturing the meaning of the pre-training data, which is computationally expensive and time-consuming [7].
In each training epoch, the model tries to predict the next token, adjusts its parameters through backpropagation and gradient descent, and repeats the process [7].
The result of pre-training is a base model, which is essentially a document generator [8].
Fine-tuning adapts the base model to specific tasks, using smaller, labeled datasets [9].
LLMs use beam search to lay out a string of next tokens and compare multiple pathways [10].
LLMs can “hallucinate,” or generate factually incorrect information, because they are predictive engines and not knowledge stores [11].
LLMs are not search engines and they do not go into a database to pull information [12].
Embeddings:
An embedding is a vector, or an array of numbers, representing the model’s understanding of a word [5].
Each value in an embedding signifies a dimension of the model’s understanding [13].
Similar words, used in similar contexts, have similar embeddings, forming clusters of related words [13].
Embeddings can be visualized in two dimensions, where each dimension is color-coded [13].
Embeddings can be interpolated, meaning the vector for “king” minus the vector for “man” plus the vector for “woman” results in a vector close to that of “queen” [2].
Embeddings can be stored to capture the semantic relevance of text and enable semantic search [2].
Embeddings are flattened representations of the information contained in a large language model [2].
The value vector is the meaning of the word, while key and query vectors act as output and input [6].
The key and query vectors can be considered the “plumbing” that underlies language, connecting words on a deeper level [6].
Additional Insights:
The quality and biases of the model are determined by the data it is trained on [1].
AI research started in the 1950s and 60s, followed by an “AI winter” in the 1970s and 80s, which led to the splintering of AI into smaller fields [1].
There are concerns about representation and biases in the pre-training data, as well as environmental impact and costs of training LLMs [14, 15].
Many challenges in deploying LLMs are software engineering concerns, such as testing, version control, latency, and maintainability [16, 17].
LLMs can enhance productivity by automating tedious work and augmenting functionality [17].
Prompting is a core skill for working with LLMs, involving conditional generation [12, 18].
A prompt guides the model to generate the right output from a massive set of possible completions [19].
Prompts can be broken into modular components and improved through iteration [20, 21].
Effective prompts include a goal, a role, and an output format [22].
Other elements of a prompt may include persona, process guidance, and additional context [23].
Prompting is an iterative process and the starting point is less important than the process to improve from there [21].
Evaluation of LLM outputs is critical, and methods like ground truth datasets, user feedback, and testing should be implemented [24, 25].
There are many prompting strategies to improve the response, including setting personas, using mimic proxies, using multiple roles, and few shot prompting [26, 27].
Additional strategies include rephrasing and responding, using a cognitive verifier and the system 2 attention concept [28, 29].
Chain of thought prompting, using both zero-shot and few-shot methods, can improve the reasoning process [30, 31].
LLMs can use external tools like web search and code editors, utilizing frameworks like “react” (reason and act) [32, 33].
Post-generation strategies include asking the model to self-check and improve its answer, decomposition, and ensembling [33, 34].
The future of prompting may involve a meeting in the middle, with models and users getting better at interpreting prompts [35, 36].
Use-case specific prompting and maintainability of prompts will continue to be important [36, 37].
Large Language Models: An Overview
Large language models (LLMs) are complex AI models that learn from massive amounts of data and generate new text outputs [1]. Here’s an overview of their key aspects:
Training and Data:
LLMs are trained on massive datasets, such as the entirety of English Wikipedia (2.5 billion words) plus an additional 800 million words from a book corpus [1].
The data used to train LLMs significantly influences the quality and biases of the model [1].
The models learn to understand text input and generate new text based on the rules they infer from the training data [1].
The models capture both semantic knowledge and world knowledge, learning the relationships between words [1, 2].
Functionality and Capabilities:
LLMs can perform various tasks, including natural language processing (text classification, machine translation, text generation, speech recognition, summarization, and question answering) [3].
They are also capable of tackling tasks beyond natural language processing, such as code generation, and addressing challenges in engineering and medicine [4].
LLMs are pattern-learning machines that predict the next token in a sequence [2].
They use key, query, and value vectors in their attention mechanism to understand the relationships between words in a sentence [2].
Tokenization:
LLMs process text by breaking it down into tokens, which are then mapped to numeric IDs [4].
Tokenization aims to create linguistically or statistically meaningful units [5].
Common words are typically represented by single tokens, while uncommon words are broken down into subwords using byte pair encoding [5].
The tokenizer dictionary is fit to the entire training dataset and determines the model’s vocabulary [5].
The number of tokens for a given input is about three-fourths of the number of words [6].
Embeddings:
An embedding is a vector (an array of numbers) that represents the model’s understanding of a word, with each value in the vector signifying a dimension of that understanding [6, 7].
Similar words, used in similar contexts, have similar embeddings, forming clusters of related words [7].
Embeddings can be visualized in two dimensions, using color-coding [7].
Embeddings can be used for semantic search and to capture the semantic relevance of text [8].
Pre-training and Fine-tuning:
Pre-training is a computationally expensive process of capturing the meaning of the pre-training data [9].
During pre-training, the model tries to predict the next token in a sequence and adjusts its parameters through backpropagation and gradient descent [9].
The result is a base model, which is essentially a document generator [10].
Fine-tuning adapts the base model to specific tasks using smaller, labeled datasets [11].
Key Mechanisms:
LLMs use self-attention to determine the relevance of every word in a sentence, enabling a contextual understanding [12].
LLMs use key, query, and value vectors in their attention mechanism to understand the relationships between words in a sentence [2].
They use beam search to generate sequences of tokens, comparing multiple pathways [13].
Limitations and Challenges:
LLMs can “hallucinate,” generating factually incorrect information because they are predictive engines, not knowledge stores [14].
They are not search engines and do not pull information from databases [15].
There are concerns about biases in the pre-training data, as well as the environmental and financial costs of training [11, 16].
Deploying LLMs involves software engineering challenges, such as testing, version control, latency, and maintainability [17].
Prompting:
Prompting is a core skill for guiding LLMs, using conditional generation to produce the desired output [15, 18].
Effective prompts include a goal, a role, and an output format and can include additional context, persona, and process guidance [19].
Prompting is iterative, and the starting point is less important than the process for improvement [20].
Prompts can be broken down into modular components [21].
Various prompting strategies can be used to improve responses, such as setting personas, using mimic proxies, few-shot prompting, and rephrasing and responding [22, 23].
LLMs can also use external tools such as web search and code editors with frameworks like “react” (reason and act) [24].
Evaluation:
Evaluation of LLM outputs is critical, and methods such as ground truth datasets, user feedback, and testing are important [25, 26].
In summary, LLMs are powerful tools with a wide range of capabilities, but they also come with their limitations and challenges. Effective prompting and a strong software engineering mindset are crucial to successfully using and deploying LLMs.
Large Language Model Understanding
Model understanding in large language models (LLMs) refers to how these models process and interpret input data, especially text, and how they use this interpretation to generate new outputs [1]. The sources discuss several key aspects of this understanding:
1. Tokenization and Vocabulary:
LLMs process text by breaking it down into smaller units called tokens [2]. These tokens can be whole words, parts of words, or even punctuation [2, 3].
The goal of tokenization is to create units that are either linguistically meaningful or statistically meaningful to the model [3].
Common words are typically represented by single tokens, while uncommon words are broken down into subwords using byte pair encoding [3].
Each token is then mapped to a numeric ID, allowing the model to process the text mathematically [2].
The model’s vocabulary is the complete list of words or tokens it can understand, which is determined by the training data set [3].
2. Embeddings:
An embedding is a vector (an array of numbers) that represents the model’s understanding of a word or token [4, 5]. Each number in the array signifies a dimension of the model’s understanding [4].
Similar words, used in similar contexts, have similar embeddings, forming clusters of related words [5]. For example, the embeddings for “woman” and “girl” might be similar, reflecting their semantic relationship [6].
These embeddings capture not only the meaning of words but also their relationships [7]. They do not distinguish between semantic knowledge and world knowledge [7].
Embeddings are a flattened representation of the information that is contained in a large language model [4].
3. Self-Attention:
LLMs use a mechanism called self-attention to understand the context of a word within a sentence [8].
Self-attention allows the model to determine the relevance of every other word in the sentence to the current word being processed [8]. This contextual understanding is essential for processing language effectively [8].
The model uses key, query, and value vectors in the attention mechanism [7]. The value vector represents the meaning of a word; the key vector represents what contextual meaning that word has to offer to other words in the sentence; and the query vector represents what meaning other words in the sentence have to offer the current word [7].
4. Pattern Learning:
LLMs are fundamentally pattern-learning machines [7]. They learn from the massive amounts of training data by identifying patterns and relationships between words and tokens [1].
During pre-training, the model tries to predict the next token in a sequence and adjusts its parameters based on its success or failure [9]. This iterative process allows it to develop an understanding of the data [9, 10].
The model’s understanding of the dataset is captured in its parameters, specifically in the model’s weights which are mathematically adjusted through backpropagation [10].
5. Pre-training and Fine-tuning:
The pre-training process is about capturing the meaning of the pre-training data [9].
The result of pre-training is a base model that is only capable of generating documents [10].
Fine-tuning is the process of adapting a base model to a variety of tasks by training it on smaller, more specific datasets [11].
6. Limitations:
LLMs do not have a true understanding of facts or the world [7, 12]. They have an embedded representation of words and their relationships, which is not the same as knowing facts [7].
Because they are predictive engines, they may produce factually incorrect information, known as “hallucinations” [12].
LLMs also do not have “system two” or deliberate thinking, and instead operate on a word association basis responding instinctively [13].
In summary, model understanding in LLMs involves a complex interplay of tokenization, embeddings, self-attention mechanisms, and pattern learning. These models don’t have human-like understanding but are capable of sophisticated language processing and generation by learning from massive amounts of data.
Large Language Model Self-Improvement
Self-improvement in the context of large language models (LLMs) refers to the mechanisms and processes that enable these models to enhance their performance and adapt to new tasks. The sources describe several key aspects of this self-improvement, particularly focusing on how these models learn and refine their abilities through training and other means:
Self-Supervised Learning: One of the most significant innovations in LLM development is the use of self-supervised learning [1]. Unlike supervised learning, which requires manually labeled data, self-supervised learning allows models to create their own labels directly from the pre-training data [1]. For example, in text-based LLMs, the input is a sequence of tokens, and the label is simply the following token. This approach enables models to be trained on massive unlabeled datasets [2].
Iterative Training: During the training process, LLMs go through multiple rounds, or epochs, of learning [1]. In each epoch, the model processes batches of the pre-training data and attempts to predict the next token in the sequence. After each attempt, the model evaluates how close it was to the correct answer and adjusts its parameters through backpropagation and stochastic gradient descent to improve its predictive ability [1].
Fine-Tuning: After pre-training, LLMs can be further improved through fine-tuning [3]. This involves training the model on smaller, task-specific datasets to adapt it for particular applications, such as question answering or acting as a helpful assistant. Fine-tuning allows LLMs to go beyond simply generating documents and instead perform specific, defined tasks [2, 3].
Reinforcement Learning: Models like AlphaGo demonstrate the power of reinforcement learning in self-improvement [4]. Version 1.0 of AlphaGo was trained by imitating human players, but version 2.0 was given a simple reward function for winning games and allowed to play millions of games, reinforcing the decisions that led to victory. This approach allowed the model to surpass human-level performance [4]. This same thread of self-improvement through reinforcement is seen in large language models as well [4].
Contextual Understanding: LLMs use mechanisms like self-attention to understand the context of words within a sentence [5]. By determining the relevance of every other word to the current word, the model develops a contextual understanding of language, which significantly improves its ability to generate meaningful text [5].
Continuous Iteration: The development and improvement of LLMs are iterative processes. For example, tokenizers are continuously modified to develop a more fine-grained system of representation [6]. Similarly, models are continuously refined through ongoing data collection and model improvement [7].
Prompt Engineering: LLMs improve through iteration of prompts, where models are better able to produce desired responses by changing the way that they are prompted [8, 9].
Key shifts:
LLMs have shifted from specialized models trained for one specific task to models that can do many things well [4].
The models are capable of self-improvement and can be adapted to different tasks using fine-tuning [3, 4].
In summary, self-improvement in LLMs is a multifaceted process that involves self-supervised learning, iterative training, fine-tuning, and reinforcement learning. These mechanisms enable LLMs to learn from data, refine their understanding of language, and adapt to perform a variety of tasks more effectively [1, 4].
Prompt Engineering: A Comprehensive Guide
Prompt engineering is the practice of designing and refining prompts to effectively guide large language models (LLMs) to produce desired outputs [1, 2]. It involves understanding how LLMs interpret natural language and using that understanding to craft inputs that elicit specific, intended responses [3]. The sources emphasize that prompt engineering is a crucial skill for working with LLMs due to their versatility and the need to condition them for specific tasks [2].
Key aspects of prompt engineering:
Conditional Generation: Prompting is fundamentally about conditional generation [3]. An LLM generates output conditioned on the input it receives [3]. The prompt is the condition that guides the model toward a particular kind of response [3].
Subtractive Process: Effective prompting involves narrowing down the vast range of possible responses to a more specific set [3]. It is a subtractive process where the goal is to produce prompts that elicit desired outputs and avoid undesired ones [3].
Components of a Prompt:
Goal: Defines what the model should do [4].
Role/Persona: Specifies how the model should approach the task [4, 5]. Using a persona can guide the model to emulate real-world or fictional characters to condition the response [5, 6].
Format: Dictates how the output should look [4].
Process Guidance: Provides instructions on how the model should reason through the task [6].
Additional Context: Includes any external information that the model should reference [6].
Prompting Strategies:
Clear Instructions: Prompts should have clear, itemized instructions that define the primary task, key terms, and any additional tasks [7]. The less the model is asked to do at one time, the better it tends to perform [7, 8].
Delimiters: Formatting and delimiters (like markdown or XML tags) provide structure that LLMs respond well to [7]. These are not universal and vary by model [7, 9].
Structured Output: Specifying the format, length, and structure of the output improves reliability [10].
Mimic Proxy: Using an element of culture or behavior that’s learned by imitation can help the model draw on archetypes [5]. For example, having a model engage in a student-teacher dialogue [5].
Few-Shot Prompting: Providing examples of the desired input-output pairs can be effective when examples are more instructive than descriptions [11].
Chain of Thought (CoT): Encouraging the model to think step-by-step is a powerful way to make implicit assumptions explicit. Zero-shot CoT involves simply adding “Let’s think step by step” [12, 13]. Few-shot CoT provides examples of reasoning steps [13].
Access to External Tools: Providing the model with tools such as a web search, code editor, or function calling can enhance its ability to respond effectively [10, 14]. The model should be guided to use the tools as needed through a process of thought, action, and observation [15].
Rephrase and Respond: A strategy where the model improves upon the user’s input by rephrasing it [16].
Self-Consistency: Generating multiple responses from the model and selecting the most common response [17].
Decomposition: Breaking a complex problem into smaller subproblems to allow the model to address each piece separately [18].
Emotional Appeals: Using emotional appeals can condition a particular response [10].
Prompt Engineering for User Input:
Scaffolding: Developers must provide context and structure to user input, as users likely haven’t studied prompt engineering [19].
Guardrails: Prompts must be designed to mitigate risks, validate user inputs, and screen outputs [20]. Since LLMs can be used to run user code, protecting against malicious actors is important [20].
Iterative Process: Prompt engineering is not about landing on the perfect prompt immediately; it is an iterative process of methodical improvement [21, 22].
Importance of Maintainability:
Modular Design: Prompts should be split into modular components to make them readable, maintainable, and flexible [21].
Version Control: Versioning and logging are important to track progress [22, 23].
Testing: It is important to test prompts with a ground truth dataset to confirm that a model is working as intended [20, 24].
Evaluation and Optimization:
Ground Truth Data Set: Establishing a ground truth data set of inputs and acceptable outputs is critical for both development and production [20].
Monitoring: Regularly monitoring the model in production and collecting user feedback is critical for maintaining and improving performance [25, 26].
Future Trends:
LLMs may become more adept at interpreting prompts, but use case specific prompting will likely remain valuable [17, 27].
Focus will be on readability, tone, prompt design patterns, and versatility across models [27]. Multimodality will also become an area of focus as models process more diverse input types [28].
In summary, prompt engineering is the art and science of crafting effective instructions for LLMs, combining clear communication with an understanding of how these models process language, make inferences, and provide responses [12]. It requires a methodical approach, focusing on both the structure of the prompt and the intended reasoning process [12].
How Large Language Models Actually Work | Full course lecture | James Laff
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
This interview features Abdul Quader Siddiqui, a Bangladeshi freedom fighter, reflecting on the country’s history since its liberation war. He critiques the dominant narrative surrounding the war, particularly the portrayal of Sheikh Mujibur Rahman, and challenges the current political climate, expressing concerns about corruption and a lack of genuine democracy. Siddiqui also discusses the roles of India and Pakistan in the war and advocates for a more inclusive and accurate historical understanding of Bangladesh’s independence. Finally, he offers his perspective on the political activism of young people and the future of the country.
Bangladesh Liberation War: A Study Guide
Short Answer Quiz
According to the speaker, what was the primary goal of the Liberation War, and has it been achieved?
What is the speaker’s view on the claim that only the Awami League represents the pro-liberation forces?
What is the speaker’s opinion of Sheikh Mujibur Rahman and his role in the independence movement?
According to the speaker, what is the significance of the destruction of Bangabandhu’s portrait and house?
How does the speaker view the actions of Jamaat-e-Islami during the Liberation War, and how does he see their role in current Bangladeshi society?
What is the speaker’s perspective on India’s role in the Liberation War?
What does the speaker think about the declaration of independence and the role of Sheikh Mujibur Rahman and Ziaur Rahman?
What is the speaker’s critique of Sheikh Hasina’s leadership of the Awami League?
How does the speaker view the idea of family-based political leadership in Bangladesh?
What does the speaker think of the young generation’s role as a pressure group in politics and their call for reforms?
Answer Key
The speaker states the primary goal was freedom from the deprivation imposed by Pakistan, but he believes the dreams of a free country have not been fully realized even after more than 50 years.
The speaker disagrees, arguing that it is a false narrative and that the claim that all who are not Awami League are Razakars is incorrect.
The speaker acknowledges Mujibur Rahman’s significant contributions, but also suggests he is not the sole hero and that he was not without faults.
The speaker condemns it as a heinous crime and says that it is a sign of the current political problems, noting it should not have happened if the country was true to the values of the liberation war.
The speaker condemns Jamaat-e-Islami for their direct involvement in atrocities during the war. However, he also says that current members who weren’t involved in the war deserve the same rights as everyone else while he says that the organization will never be able to atone for the past actions of their predecessors.
The speaker acknowledges India’s help but states it was primarily for India’s own strategic reasons. He also points out the important role played by Bangladeshi freedom fighters in the victory.
The speaker values the declaration of independence and acknowledges that both Sheikh Mujibur Rahman and Ziaur Rahman played important roles, noting that even if Ziaur Rahman declared on behalf of Sheikh Mujibur Rahman it was still a valid declaration.
The speaker criticizes Sheikh Hasina for straying from the original ideals of the Awami League, for holding two positions of power, and for her corrupt practices.
The speaker is against family-based political leadership, expressing that it has no place in Bangladesh and should not continue to be the norm.
The speaker is positive about the young generation’s activism and believes that they need to win people’s hearts to run the state successfully instead of using pressure tactics.
Essay Questions
Analyze the speaker’s critique of the current political landscape in Bangladesh, focusing on how it relates to the legacy of the Liberation War.
Compare and contrast the speaker’s views on Sheikh Mujibur Rahman and Sheikh Hasina, discussing how their leadership has shaped the post-independence trajectory of Bangladesh.
Evaluate the speaker’s stance on the role of India in the Liberation War. Is he appreciative, critical, or both? Provide evidence from the text.
Explore the complex relationship between historical memory and political narratives in the context of the Bangladesh Liberation War. How does the speaker challenge the official narrative?
Discuss the speaker’s vision for the future of Bangladesh, based on his comments regarding democracy, leadership, and the role of the younger generation.
Glossary of Key Terms
Assalamu Alaikum: A common greeting in Islam, meaning “peace be upon you.” Bangabandhu: An honorific title, meaning “Friend of Bengal,” referring to Sheikh Mujibur Rahman. Bangbir: A term meaning “Hero of Bengal,” used to address Abdul Quader Siddiqui in the provided text. Bakshal: The Bangladesh Krishak Sramik Awami League, a political party formed by Sheikh Mujibur Rahman in 1975, which restructured the nation into a one-party system. Freedom Fighter: An individual who participated in the Bangladesh Liberation War of 1971. Jamaat-e-Islami: A religious political party in Bangladesh that opposed the Liberation War and is accused of collaboration with Pakistani forces. Liberation War: The war fought in 1971 for the independence of Bangladesh from Pakistan. Razakar: A derogatory term used to refer to collaborators of the Pakistani army during the 1971 Liberation War, particularly those who were against the independence of Bangladesh. Sheikh Hasina: The current Prime Minister of Bangladesh and daughter of Sheikh Mujibur Rahman. Sheikh Mujibur Rahman: The founding leader of Bangladesh, also known as Bangabandhu, who led the country during its Liberation War and early years of independence. Shramik Janata Party: The name of the political party founded by Abdul Quader Siddiqui, as mentioned in the text. Tikka Khan: A Pakistani Army General known for his brutal actions during the 1971 Liberation War in Bangladesh. Yahya Khan: The President of Pakistan during the 1971 Liberation War. Ziaur Rahman: A former President of Bangladesh and a military leader in the Liberation War who declared the independence of Bangladesh on behalf of Sheikh Mujibur Rahman.
Siddiqui on Bangladesh: A Critical Perspective
Okay, here’s a detailed briefing document based on the provided text, which appears to be an interview with Abdul Quader Siddiqui, a freedom fighter and political figure in Bangladesh:
Briefing Document: Analysis of Abdul Quader Siddiqui Interview
Date: October 26, 2023 (Assumed, as no date given in source)
Subject: Key themes and critical perspectives from an interview with Abdul Quader Siddiqui regarding Bangladesh’s history, politics, and current state.
Source: Excerpts from an Interview on RICL TMA Straight Cut, featuring Deepti Chowdhury and Abdul Quader Siddiqui.
Overview:
This interview provides a critical and often contentious view of Bangladesh’s history, particularly its liberation war and subsequent political landscape. Siddiqui, a prominent figure in the liberation war, expresses deep disappointment with the country’s trajectory, criticizing the current government, and highlighting what he sees as significant historical inaccuracies and ongoing injustices. He challenges the dominant narrative of the Awami League and its leader, Sheikh Hasina, while also giving nuanced perspectives on other key figures like Sheikh Mujibur Rahman and Ziaur Rahman.
Key Themes and Ideas:
Disillusionment with Post-Liberation Bangladesh:
Siddiqui expresses profound disappointment with the state of Bangladesh since its independence. He states bluntly, “Bangladesh is not good at all.” He suggests the sacrifices made during the liberation war have not yielded the desired outcomes of a truly free and prosperous nation. He criticizes the claim that the country was completely liberated, stating that “it will be a lie if we say that we freed Bangladesh from the hands of Pakistanis with our lives.” He implies that the ideals of the liberation war have not been met, and there’s a lack of the desired progress.
Critique of the Awami League and Sheikh Hasina:
Siddiqui is highly critical of the Awami League and its current leader, Sheikh Hasina. He accuses her of not upholding the ideals of the party’s founders and for engaging in corruption and vote-rigging. He argues that “Sheikh Hasina led Awami League I usually call it Hasina League no leadership developed here no personality developed here.” He believes that she has turned the party into an autocracy. He contrasts her actions with the party’s early ideals stating that “Sheikh Hasina was the president of Awami League for 16 years and 15 and a half years, she was the prime minister, then she acted against her father’s ideals.”
Re-evaluation of Sheikh Mujibur Rahman’s Legacy:
While acknowledging Sheikh Mujibur Rahman’s significant contributions to the nation’s liberation, Siddiqui contests the notion that he was the sole hero of the liberation war, “It is also not true that Mujib has been singled out as a hero and we have not been able to highlight Sheikh Mujib as much as it should have been.” He criticizes the portrayal of Mujibur Rahman by the Awami League, which he feels has been exaggerated, and believes that Mujib was unable to fulfill the promises of the country’s freedom. He also says that “the way the Awami League has tried to call Sheikh Mujib Bangabandhu is not Bangabandhu.” He also believes that the second revolution of Bangabandhu was tarnished and not fully understood.
Siddiqui highlights that Mujib himself recognized some shortcomings in his leadership, “Sheikh Mujibur Rahman has to admit that he could not do it to some extent…“
Recognition of Ziaur Rahman’s Role:
Siddiqui acknowledges Ziaur Rahman’s importance, stating, “Ziaur Rahman is a great leader and it must be accepted.” He notes Ziaur Rahman’s declaration of independence as valuable and significant to the people during the war. He seems to argue that while Mujibur Rahman made the initial call, it was Ziaur Rahman who actively participated. He also contends that historical narratives have unfairly undermined Zia’s contribution.
The Nature of the Liberation War:
Siddiqui points out the complexity of the war and how it was not solely the Awami League that contributed. He suggests that the narrative promoted by the current government is one-sided, where, “only those who make Awami League are the pro-independence forces, the pro-liberation forces, and all the rest are the forces of Razaka, the rest are the opposition forces.“
He emphasizes that many individuals and groups participated in the liberation, and their contributions should not be ignored.
He emphasizes the role of the freedom fighters in the victory, arguing that Indian Army’s victory is not the only contributing factor, noting that “lakhs of freedom fighters have stayed with the Indian forces like the shadow of the Indian forces, they have stayed ahead, they have stayed behind, that is why the Indian forces have won.“
Critique of the Anti-Discrimination Movement & Violence:
Siddiqui is critical of those who have vandalized Bangabandhu’s portraits and home, calling it a “heinous crime in the judgment of history“, emphasizing that disrespecting Bangabandhu means disrespecting freedom. He suggests that while he disagrees with many of his policies, respect is due to him and to any human being. He hopes those involved will express regret, while also stating that, “I believe in my heart that they did not do this.”
He states that those who oppose the government should be thankful to the Jamaat-e-Islam, despite their negative actions during the war.
Rejection of Family Politics:
Siddiqui rejects the idea of family-based politics and leadership, noting that “there is no place for the family system in Bangladesh.” He highlights that a system where leadership is passed down through family ties is not sustainable or good for democracy. He also mentions how the present system has continued for years.
The Role of the Young Generation:
Siddiqui views the new generation as important to the future, emphasizing that they “will run the state and the country“. He suggests that the current generation should focus on people’s will and should strive to win people’s hearts instead of resorting to pressure.
Relationship with India:
Siddiqui stresses the importance of Bangladesh having an equal relationship with India and does not want to be treated as a younger brother. He highlights that the Indian Army did not win any wars except for the 71 liberation war because of the freedom fighters from Bangladesh and their support.
Key Quotes:
“Bangladesh is not good at all.”
“It will be a lie if we say that we freed Bangladesh from the hands of Pakistanis with our lives.”
“only those who make Awami League are the pro-independence forces, the pro-liberation forces, and all the rest are the forces of Razaka, the rest are the opposition forces.”
“Sheikh Hasina led Awami League I usually call it Hasina League no leadership developed here no personality developed here.”
“Ziaur Rahman is a great leader and it must be accepted.”
“It is also not true that Mujib has been singled out as a hero and we have not been able to highlight Sheikh Mujib as much as it should have been.”
“the way the Awami League has tried to call Sheikh Mujib Bangabandhu is not Bangabandhu.”
“There is no place for the family system in Bangladesh”
“If you abuse Bangabandhu, you also abuse eat your parents will also be abused”
Analysis & Implications:
This interview reveals deep-seated dissatisfaction with the current political situation in Bangladesh and a strong desire for change. Siddiqui’s comments challenge the official narrative surrounding the liberation war and its heroes. He believes that the country has strayed from its founding principles and is currently plagued by corruption and authoritarianism. His critical perspectives have the potential to resonate with many in Bangladesh who are similarly disillusioned. His commentary also highlights the deep political divisions that persist in the country. The interview also raises the question of how the country should move forward after a contentious political history. Siddiqui seems to emphasize the need for a new generation of leadership and for a more equitable system of governance.
Conclusion:
This interview with Abdul Quader Siddiqui provides valuable insight into the complexities and challenges facing Bangladesh. His perspectives highlight the need for a more inclusive and accurate historical narrative, a reevaluation of leadership, and a commitment to upholding the democratic values for which the country fought. It is imperative to understand these viewpoints in order to properly assess the current state of the country and its future trajectory.
Bangladesh: Liberation, Legacy, and Future
Frequently Asked Questions: Bangladesh Liberation War and Politics
What is the speaker’s overall assessment of Bangladesh’s current state since the Liberation War, and what is the basis of this assessment? The speaker expresses deep dissatisfaction with the current state of Bangladesh, stating that it is “not good at all” even 53-54 years after independence. He believes that while the country gained freedom from Pakistan, the initial goals and dreams of the Liberation War have not been realized. He criticizes the lack of progress in the country, stating it would be a “lie” to say that Bangladesh is in a good place since the war and that the war was not about a complete victory over all the opposing ideas and ideals. The speaker also points out that there was the aim for a country free from discrimination which has not been achieved.
How does the speaker view the role of Sheikh Mujibur Rahman in Bangladesh’s history and his legacy? While acknowledging Sheikh Mujibur Rahman’s significant contribution to the liberation struggle, the speaker doesn’t portray him as the sole hero of the independence movement. He argues that while Mujib did a lot, he didn’t do it alone and the idea of a single hero is a distortion of history, and there are many who contributed to the freedom of Bangladesh. The speaker criticizes the attempts to focus only on him and to brand him “Bangabandhu” in the way that he has been. He also admits that there are ways in which Mujibur Rahman’s government failed and suggests that the attempt to tarnish the second revolution is detrimental to a full understanding of history. He also condemns the destruction of Bangabandhu’s portraits and house as heinous acts.
What is the speaker’s opinion of the Awami League and Sheikh Hasina’s leadership? The speaker is critical of the Awami League under Sheikh Hasina’s leadership, stating that the party is not living up to its ideals and has become corrupt. He points out that under Sheikh Hasina’s leadership, no other leader within the party has developed and that her leadership is the final word. He notes that there is a focus on authority rather than ideals. He also accuses the government of stealing votes and not conducting fair elections. Furthermore, the speaker criticizes her for acting against her father’s ideals as she is both the head of the party and the government. The speaker says the party cannot use Sheikh Hasina as a means to facilitate the freedom war and will benefit without her involvement.
What is the speaker’s perspective on the role of Ziaur Rahman and his declaration of independence? The speaker recognizes Ziaur Rahman as a great leader and acknowledges his declaration of independence as extremely valuable, particularly when broadcast on the radio during the war. He acknowledges that there was a lot of radio broadcasting of his message in the BBC. He seems to suggest that the declaration was valid at the time, given that he held the relevant authority, and that all actions taken during a movement are valid as long as people support them. He contrasts the legitimacy of Ziaur Rahman’s declaration to a hypothetical declaration from a professor who has been sacked, and he suggests that to leave Bangabandhu out of the declaration lessens it’s value.
How does the speaker view the current youth movements and their demands for reforms? The speaker supports the youth movements, highlighting their efforts and the need for a complete overhaul of the system. He sees the youth as the future of the country and believes that winning the hearts of the people is the only way to govern effectively. He does not believe that reform should be achieved through a pressure system. He views the youth as having the energy and the ability to move the country forward.
What is the speaker’s view on the role of India in Bangladesh’s liberation war? The speaker acknowledges India’s assistance during the Liberation War and believes that Bangladesh should be grateful. However, he insists that the victory was not solely India’s but a shared effort with the Bangladeshi freedom fighters. He points out that the Indian army did not win many wars and that the liberation of Bangladesh was exceptional because of the sacrifices of Bengalis alongside the Indian forces. The speaker does not believe Bangladesh should be subservient to India but be considered on equal status as a neighboring country.
How does the speaker view the Jamaat-e-Islami and its members today? The speaker is critical of Jamaat-e-Islami’s actions during the Liberation War but believes that the current members who were born in an independent Bangladesh should be considered equal citizens with equal rights. He makes a distinction between the past crimes of the party and the current membership. However, he does say that until the crimes of the party are absolved, those in the party cannot be completely free from being associated with those crimes. He believes that if people are anti-independence, they should not be living in the country.
What are the key issues that the speaker believes need to be addressed in Bangladesh’s political landscape? The speaker identifies several key issues: the distortion of history regarding the Liberation War, the lack of development within political leadership and the corruption of the Awami League, the need for fair elections and political reform, the necessity to address historical injustices committed by groups like Jamaat-e-Islami while acknowledging the rights of present members, and finally the need to move beyond hero-worship towards collective appreciation of all who contributed to independence, and most importantly to build a country that reflects the original aims of the war of liberation.
Bangladesh: Liberation, Legacy, and the Struggle for Democracy
Okay, here’s a detailed timeline and cast of characters based on the provided text:
Timeline of Main Events
Pre-1970: The text refers to the discrimination faced by Bengalis in Pakistan, leading to the 1970 election.
1970: Pakistan does not accept the results of the 1970 election where Bengalis had a major victory.
1971 (March 7): Sheikh Mujibur Rahman’s speech where he urges people to resist with whatever they have.
1971 (March 25): The text suggests that if the movement hadn’t continued, they may not have heard of Ziaur Rahman. This is generally considered the start of the Liberation War.
1971: The Liberation War of Bangladesh takes place. The text refers to the Pakistani Army having 300,000 soldiers, and the Bengalis having 16-17,000, and the war as having been against the “deprivation of Pakistan”. The Liberation war is described as a time when “every hour on the hour, it was played Bangladesh was saved from the radio.”
1971 (December 16): Victory Day. The text mentions that the allied forces (Indian and Bangladeshi) enter Niazi Cave. It states that Abdul Quader Siddiqui was the only Bengali and the other three were Indian: two brigadiers and one major general (Major General Nagra.)
Post-Liberation War: The text suggests that the country was not run properly after the war.
Post-Liberation War: Refers to a period when Sheikh Mujibur Rahman had “vanquished” the Awami League, and it had reemerged from the Bakshal, and that this proved Bakshal’s decision was wrong.
Unknown Date (Post-Liberation War): Sheikh Mujibur Rahman is killed by Bengalis. The text notes a “second revolution” was tarnished by this killing.
Later: The text mentions that the house and museum of Bangabandhu Sheikh Mujibur Rahman were vandalized and set on fire. The text suggests this is a “heinous crime.”
Unknown Date: There was a time when the declaration of independence in Ziaur Rahman’s voice was “broadcasted many times on BBC.”
Current (as of the interview): There is an anti-discrimination movement, and students are agitating and calling for an overhaul of the state system followed by elections. There is criticism of the current government under Sheikh Hasina, with claims of corruption, and criticisms that the “Hasina League” lacks proper leadership development. There are questions about election integrity, with the statement that “the previous governments have ruined” it.
Recent: There are criticisms of the ruling party, the Awami League for trying to make Sheikh Mujibur Rahman into a single hero of the independence, rather than an important figure in a broader struggle.
Cast of Characters
Abdul Quader Siddiqui: The interviewee. Described as a “hero freedom fighter” and “Bangbir” (Hero of Bengal) who worked as an organizer during the Liberation War. He is also the Founder President of Shramik Janata Party. He seems to have been present at the surrender in “Niazi’s Cave.”
Deepti Chowdhury: The interviewer. She is with RICL TMA Straight Cut organization.
Sheikh Mujibur Rahman (Bangabandhu): A central figure in the text. Described as a key leader of the liberation movement, and “father” of the Awami League, the text indicates a debate whether he should be elevated as the hero of the war. There is criticism that the government has not “highlighted him as much as it should have been.” His house and museum were vandalized.
Sheikh Hasina: Current leader of the Awami League and Prime Minister. Criticized for her leadership style, described as making the Awami League into “Hasina League.” Her leadership is described as “the last word,” with little room for others. She is also criticized for corruption. She is mentioned as having been “the president of Awami League for 16 years and 15 1/2 years the prime minister” which is said to be against her father’s ideals. The text implies she has taken power through vote stealing.
Ziaur Rahman: Presented as a significant figure during the Liberation War, who was “in the barracks” on March 7th. His declaration of independence is described as “very valuable,” and was broadcast “many times on BBC.” The text notes that his existence might not have been known “if we could not hold the movement till March 25th.”
Maulana Abdul Hamid Khan Bhashani: Described as the “father” who gave birth to the Awami League before Bangabandhu, he is mentioned as having argued against leaders holding two positions at the same time.
Hossain Shaheed Sarwardi: Mentioned as having led the Awami League after Maulana Abdul Hamid Khan Bhashani.
Obaidul Quader: Described as a “bridge minister.” He is mentioned as not having “carried the ideals of Bangabandhu politically” and as someone who wanted to take “leadership and authority” himself.
Tajuddin Ahmed: Mentioned as someone whose daughter has written a book stating that Sheikh Mujibur Rahman did not agree to declare independence at the time.
Tikka Khan and Yahya: Their rule was described as “not at all the contribution of Bangabandhu’s daughter incompetent leader Sheikh Hasina.”
Murarji Desai, Atal Bihari Vajpayee, Narendra Modi: Leaders from India who are mentioned as examples of political transitions, in contrast with the veneration of Sheikh Mujibur Rahman, they are all meant to show that “no one could destroy anyone’s museum.”
Pandit Jawaharlal Nehru: Indian leader mentioned in the context of the 1962 war with China and the war with Pakistan in 1965.
Niazi: Pakistani army general who was in command during the surrender at the end of the war.
Major General Nagra: Indian army officer who was with Abdul Quader Siddiqui in the surrender at Niazi Cave.
Brigadier Sunsin Clear: Indian army officer who was with Abdul Quader Siddiqui in the surrender at Niazi Cave.
Prof. Yunus: Mentioned as having been sacked.
Students: Described as leading the current agitation and demanding reforms to the state system.
Key Themes and Conflicts
The Legacy of the Liberation War: The text highlights the ongoing debate about who should be credited for the independence of Bangladesh. There is conflict over the role of Sheikh Mujibur Rahman versus others, including freedom fighters and Ziaur Rahman. There are statements that suggest an attempt to rewrite the history by “making Sheikh Mujibur Rahman a single hero.”
Criticism of the Current Government: There is strong criticism of Sheikh Hasina’s leadership, with accusations of corruption, authoritarian tendencies, and election rigging. The text implies the current government is not adhering to the ideals of the liberation movement.
Political Polarization: The text highlights the deep divisions within the country, with a clear distinction between those who are pro-Awami League and those who are opposed, and that those opposed are labeled as “forces of Razaka.”
Ongoing Struggle for Democracy: The interviews makes clear the desire for democratic reform and fair elections, with student agitation being seen as an important movement for change.
Let me know if you have any other questions or sources you’d like me to analyze!
Bangladesh Liberation War: Politics and Legacy
The sources discuss the Liberation War of Bangladesh, its aftermath, and its continuing impact on the country’s politics and identity. Here’s a breakdown of key points:
The War and its Goals: The war was fought against the deprivation imposed by Pakistan [1]. The aim was to achieve freedom and independence for Bangladesh [1]. It is stated that the war was not a complete victory for the freedom fighters as the dream of a free country is still not fully realized even 53-54 years later [1].
The Role of Different Groups:Bengalis in the Pakistan Army: At the time of the war, there were around 300,000 members in the Pakistan Army, with 16-17,000 of them being Bengalis [1].
Freedom Fighters: The freedom fighters played a crucial role in the war and fought alongside Indian forces [2]. They are described as being like “the shadow of the Indian forces” [2].
Jamaat-e-Islami: The Jamaat-e-Islami is criticized for not only supporting Pakistan politically but also forming armed groups that committed atrocities [3]. However, it is also mentioned that the current members of Jamaat-e-Islami were mostly born in an independent Bangladesh and have the same rights as other citizens, as long as they atone for the crimes of their predecessors [3].
Awami League: The Awami League is viewed as the pro-independence force [4]. The party’s history and the roles of its leaders, including Sheikh Mujibur Rahman and Sheikh Hasina, are discussed in detail [2, 4].
Sheikh Mujibur Rahman’s Role: Sheikh Mujibur Rahman is considered a key figure in the liberation movement [4]. While some acknowledge his significant contributions, there is also a view that he was not the sole hero of the war [4, 5]. It is mentioned that he may have not agreed to declare independence at a certain time [6]. The sources note that the Awami League has, at times, presented him as the single hero of the war [4]. It is also stated that Bangabandhu’s house and portrait were vandalized which is considered a “heinous crime” [4, 5].
Ziaur Rahman’s Role: Ziaur Rahman’s declaration of independence is deemed very valuable [6]. It is mentioned that while Bangabandhu called for resistance, Ziaur Rahman did not come out to face the enemy but remained in the barracks [5]. However, Ziaur Rahman is also acknowledged as a great leader [5].
India’s Involvement: India’s role in the war is acknowledged, but it is clarified that it was not a victory solely for the Indian army [2, 7]. The victory was possible because of the sacrifices of the Bangladeshi people [2]. India’s strategic goals were to squeeze Dhaka and negotiate the Pakistani army’s return, rather than occupying Dhaka [7].
Post-War Issues:The country’s inability to be run properly after the war is acknowledged, even by Sheikh Mujibur Rahman [4].
The political landscape has been shaped by the war, with the Awami League often claiming to be the sole pro-liberation force, while other parties are considered to be the opposition [4].
The need for reforms in the election process is highlighted [3].
The current political climate is seen as problematic, with a focus on individuals rather than ideals [2].
The Current Political Situation: There are concerns about the current state of democracy and the need for genuine representation of the people [8]. The youth is seen as a pressure group demanding reforms [8]. It is suggested that winning the hearts of the people is crucial for a better future for the country [8]. The interview concludes with hope for a “golden sun” and a beautiful Bangladesh [8].
The sources emphasize that the Liberation War was a complex event with multiple actors and various interpretations of its history and impact. It continues to influence the political landscape and the identity of Bangladesh [4].
Bangladesh’s Political Crossroads
The sources provide a detailed look at the political future of Bangladesh, particularly concerning the Awami League and the role of the younger generation. Here’s a breakdown of key points:
Awami League’s Future: The Awami League is described as a party born through struggle, with its leadership evolving from Maulana Abdul Hamid Khan Bhashani and Hossain Shaheed Sarwardi to Bangabandhu Sheikh Mujibur Rahman [1]. However, it is argued that current leaders like Sheikh Hasina and Obaidul Quader have deviated from the ideals of Bangabandhu [1]. The party is seen as facing challenges, with some suggesting it is currently in a weakened state and on the streets [1, 2]. There’s a view that the party’s reliance on Sheikh Hasina’s leadership has stifled the development of new leaders and personalities within the party [3].
Sheikh Hasina’s Role: Sheikh Hasina’s leadership is criticized for not adhering to her father’s ideals, particularly concerning holding multiple positions in the government and the party [1]. It’s argued that her leadership has become overly centralized and authoritarian [3]. The sources also mention that she came to power by stealing votes and that her government has failed to implement necessary reforms [3]. The sources suggest that the Awami League’s association with Sheikh Hasina may be a hindrance to its political future [2]. It is stated that Sheikh Hasina might need to struggle for 15 years to regain political strength [2].
Need for Reforms: The sources emphasize the need for significant reforms, particularly in the electoral process [3]. The current system is seen as flawed, with allegations of vote-stealing and a lack of genuine voter participation [3]. There’s a call for creating an environment where people can vote freely and the right voter can go to the polling station [3]. It’s suggested that the previous governments have ruined the election process and that reforms are necessary to ensure fair elections [3].
Role of the Younger Generation: The younger generation is portrayed as a pressure group that is actively involved in politics and demanding reforms [2]. They are seen as being present in the interim government and on the streets, advocating for change [2]. The sources suggest that they will play a crucial role in shaping the future of the country [2]. It’s emphasized that the future of the state and the country will be determined by the new generation, and not by pressure tactics [2]. The need to win the hearts of the people is highlighted as crucial for the success of any political movement [2].
Political Instability and Change: The sources suggest that the political landscape is unstable and that change is inevitable. The idea that “the beggar on the street will be the king tomorrow” indicates a belief in the potential for significant shifts in power [2]. There’s a call for letting “people’s democracy continue” [2]. The sources express hope that the country will overcome its current challenges and move towards a better future [2]. The idea of a “golden sun” rising is used as a symbol of this hopeful future [2].
Family System: It is stated that there is no place for the family system in Bangladesh [2].
Importance of Ideals: There is a concern that current politics are focused on individuals rather than ideals [1, 3]. There’s a call for sincerity in making reforms and a focus on genuine representation of the people [3].
In conclusion, the sources suggest that the political future of Bangladesh is uncertain, with potential for significant changes. The Awami League faces challenges due to its leadership and lack of adherence to its founding ideals. The younger generation is expected to play a key role in demanding reforms and shaping a better future for the country.
The Awami League: History, Leadership, and Future Prospects
The sources discuss the Awami League extensively, covering its history, leadership, current state, and future prospects. Here’s a breakdown of key points:
Historical Roots: The Awami League was not founded by Sheikh Hasina, but rather emerged through struggle, with early leadership from Maulana Abdul Hamid Khan Bhashani and Hossain Shaheed Sarwardi [1]. Later, Bangabandhu Sheikh Mujibur Rahman became a key leader [1]. There were disputes in the party as early as 1957 regarding leaders holding multiple positions in government and party, which led to Sheikh Mujibur Rahman resigning his ministerial position to be only the secretary general of the Awami League [1].
Sheikh Mujibur Rahman’s Leadership: Bangabandhu Sheikh Mujibur Rahman is recognized as an important leader in the history of the Awami League [1]. However, it is noted that the Awami League has, at times, presented him as the single hero of the liberation war, which is not entirely accurate [2]. The sources also indicate that the Awami League has not highlighted Sheikh Mujib as much as it should have [2]. His ideals are referenced as a standard against which the current leaders of the Awami League are judged [1]. It is also noted that Bangabandhu’s house and portrait were vandalized, which is considered a “heinous crime” [2].
Sheikh Hasina’s Leadership: Sheikh Hasina’s leadership is heavily critiqued in the sources. It is argued that she has deviated from her father’s ideals, particularly regarding holding multiple positions in the government and the party [1]. She has been the president of the Awami League for 16 years and the prime minister for 15 and a half years, which is seen as a violation of the principle that no leader should hold two positions at the same time [1]. It’s argued that her leadership has become overly centralized and authoritarian [1, 3]. The sources also mention that she came to power by stealing votes [3] and that her government has failed to implement necessary reforms [3]. The Awami League’s association with Sheikh Hasina may be a hindrance to its political future [4]. The sources suggest that Sheikh Hasina might need to struggle for 15 years to regain political strength [4]. There is a view that the party’s reliance on Sheikh Hasina’s leadership has stifled the development of new leaders and personalities within the party [3].
Current State: The Awami League is described as a party that is currently facing challenges and is on the streets [4]. The sources indicate that the party is in a weakened state [4]. There is a concern that current politics are focused on individuals rather than ideals [1]. It is stated that the Awami League, along with Sheikh Hasina, is “not doing well” [1].
Ideological Deviation: The sources argue that current leaders like Sheikh Hasina and Obaidul Quader have deviated from the ideals of Bangabandhu [1]. It’s stated that they are more focused on leadership and authority for themselves rather than the ideals of the party [1]. The party is seen as not having a clear set of ideals after Sheikh Hasina came to power [3].
Political Future: The political future of the Awami League is uncertain [4]. There is a suggestion that the party’s reliance on Sheikh Hasina is not helping its future prospects [4]. It is also suggested that the party may be able to recover if it has stamina [4]. It is thought that the Awami League will not be able to facilitate the freedom war by involving Sheikh Hasina [4].
Connection to Liberation War: The Awami League is viewed as the pro-independence force in Bangladesh [2, 5]. However, there is a view that the Awami League has tried to monopolize the narrative of the liberation war, and that it has not given due credit to all those who contributed to the independence of Bangladesh [2].
In conclusion, the sources present a complex and critical view of the Awami League. While acknowledging its historical significance and role in the liberation war, the sources raise significant concerns about its current leadership, ideological direction, and political future. The party’s reliance on Sheikh Hasina’s leadership is seen as a weakness, and there’s a call for a return to its founding ideals.
Sheikh Hasina’s Leadership: A Critical Analysis
The sources offer a critical perspective on Sheikh Hasina’s leadership and her role within the Awami League. Here’s a breakdown of key points regarding Sheikh Hasina, drawing from the sources:
Deviation from Ideals: The sources argue that Sheikh Hasina has deviated from the ideals of her father, Bangabandhu Sheikh Mujibur Rahman [1]. A key example cited is that she has held multiple positions in the government and the party, whereas her father resigned from his ministerial position to avoid doing so [1]. It’s suggested that current leaders like Sheikh Hasina and Obaidul Quader are more focused on leadership and authority for themselves rather than the ideals of the party [1].
Authoritarian Leadership: Sheikh Hasina’s leadership is described as overly centralized and authoritarian [1, 2]. The sources suggest that the party’s reliance on Sheikh Hasina’s leadership has stifled the development of new leaders and personalities within the party [3].
Illegitimate Rise to Power: The sources mention that Sheikh Hasina came to power by “stealing votes” [3]. This suggests that her legitimacy as a leader is questioned. It’s stated that she did not have a clear set of ideals when she came to power [3].
Failure to Implement Reforms: The sources criticize Sheikh Hasina’s government for failing to implement necessary reforms [3]. The sources indicate that her government has tried to deviate from the fact that no reform is possible [3].
Negative Impact on Awami League: The Awami League’s association with Sheikh Hasina is seen as a potential hindrance to its political future [2]. It’s argued that involving Sheikh Hasina will not benefit the party in the context of the liberation war and that this is what they have done for the past 16 years [4].
Weakened State of the Party: The sources indicate that the Awami League is currently in a weakened state and is “on the streets” [2, 4]. This is seen as a consequence of the current leadership and policies [4].
Need for Struggle: It’s suggested that if Sheikh Hasina wants to regain political strength, she will have to struggle for 15 years [4]. This implies that her current position is precarious and she faces significant challenges.
Not the Founder of Awami League: The sources emphasize that Sheikh Hasina did not found the Awami League, but that the party emerged through struggle [1]. The founders of the Awami League were Maulana Abdul Hamid Khan Bhashani, Hossain Shaheed Sarwardi and then Bangabandhu Sheikh Mujibur Rahman became the leader [1].
Comparison to her Father: Sheikh Hasina’s actions are often compared to those of her father. It’s noted that she has acted against her father’s ideals [1]. It’s also stated that Sheikh Mujib has not been highlighted as much as he should have been [2].
Criticism of Her Government: The sources say that Sheikh Hasina’s government has ruined the election process and failed to make necessary reforms [3].
Public Disconnect: It is noted that when Sheikh Hasina called for people to go to the polling station, no one went, including members of the Awami League [3].
In conclusion, the sources portray Sheikh Hasina as a leader who has deviated from the ideals of her father and has become overly authoritarian. Her leadership is seen as detrimental to the Awami League, and her government is criticized for failing to implement reforms and stealing votes. The sources suggest that her political future is uncertain, and she faces significant challenges in regaining political strength.
Bangladesh’s Liberation War: Contested Narratives and Unfinished Dreams
The sources provide several perspectives on the history of Bangladesh’s independence, with a focus on the roles of key figures, the liberation war, and its aftermath. Here’s a detailed discussion:
The Liberation War: The sources emphasize that the liberation war was a crucial event in the history of Bangladesh [1-3]. It’s noted that the war was fought against the deprivation imposed by Pakistan [1]. The war resulted in Bangladesh’s freedom, but it is argued that the dream of a free country has not been fully realized [1]. The war was not just a military conflict but also a struggle for the recognition of the Bengali people’s rights [1]. The war is seen as a defining moment in the country’s history, and it is asserted that it only happens once in a country [2].
Role of Key Figures:Sheikh Mujibur Rahman: Bangabandhu Sheikh Mujibur Rahman is acknowledged as a key figure in the independence movement. However, it is argued that the Awami League has, at times, presented him as the single hero of the liberation war, which is not entirely accurate [2, 4]. It’s also stated that the Awami League has not highlighted Sheikh Mujib as much as it should have [2]. He gave a speech on March 7, calling people to face the enemy with whatever they have [4].
Ziaur Rahman: Ziaur Rahman’s role in the declaration of independence is highlighted. It is mentioned that the declaration of independence in his voice was broadcasted on the radio [5]. It is also noted that while Bangabandhu called on people to face the enemy, Ziaur Rahman was in the barracks at the time [4]. It is further stated that it was valuable that the declaration of independence was made in his voice [5].
Declaration of Independence: The declaration of independence is considered a precious moment and was broadcasted during the war [5]. It is mentioned that Tajuddin Ahmed’s daughter wrote that Bangabandhu Sheikh Mujibur Rahman did not agree to declare independence at that time [5]. The declaration of independence in Ziaur Rahman’s voice is also mentioned as being broadcasted multiple times on BBC [5]. The importance of this declaration is emphasized, stating that the country was saved from the radio and airwaves through it [5].
The Pakistani Army: It is mentioned that there were about 3 lakh members in the Pakistan Army, and Bengalis were among them [1]. The source indicates that the Pakistanis did not accept the election results of the 70s, which led to Bengalis standing against them [1]. It’s noted that Bengalis got rid of Pakistan because they did not obey the vote verdict [1]. December 16th is referred to as the day of victory of the Pakistani army by some, where the word Bangladesh was not even uttered [6].
India’s Role: India’s participation in the liberation war is acknowledged, but the sources also note that it was not in India’s plan to occupy Dhaka [6]. It is mentioned that India’s goal was to squeeze Dhaka from all sides and negotiate the exit of the Pakistani army [6]. It’s emphasized that the Indian army won because of the support of the freedom fighters [7]. One source indicates that there is no history of the Indian army winning any war other than the Liberation War of 71 [7].
Post-Independence Challenges: The sources mention that the country could not be run properly after the war of independence [2]. It’s also noted that there has been a lack of progress in the 53-54 years since independence, and the country is not in good condition [1]. There’s a concern that the dreams of the liberation war have not been fully realized [1]. There is also concern that those who lost in the war were not totally defeated [1].
Contested Narratives: The sources highlight that there are different narratives about the liberation war. The Awami League is seen as trying to monopolize the narrative, with some arguing that this is not accurate. There are disagreements about who played the most crucial roles and how the events unfolded [2]. For example, it’s questioned whether Sheikh Mujibur Rahman should be considered the single hero of the war and whether Ziaur Rahman’s contribution to the war is acknowledged enough [2, 4].
Anti-Discrimination Movement: The sources discuss the anti-discrimination movement in the context of the independence war. It is mentioned that the anti-discrimination movement in 2024 is not a good sign for the country [1]. The anti-discrimination movement is seen as a continuation of the struggle for equal rights, which was also a key goal of the liberation war [1].
The Legacy of the War: The sources emphasize that the war is still relevant and the freedom gained from the war needs to be studied, seen, and understood. It’s also said that many people contributed to freedom [2]. The burning of Bangabandhu’s house and museum is considered a “heinous crime in the judgment of history” [4].
In conclusion, the sources present a multi-faceted view of Bangladesh’s independence history, highlighting the significance of the liberation war, the roles of key figures, the challenges faced after independence, and the contested narratives surrounding these events. The sources suggest that while the country has achieved independence, it is still grappling with many issues and that the ideals of the liberation war have yet to be fully realized.
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
The text provides a series of tutorials on C++ programming, covering introductory to intermediate concepts. The tutorials guide users through setting up a development environment and understanding basic syntax. It explains variables, data types, functions, classes, and object-oriented programming principles. Additionally, it shows how to handle multifile compilation and incorporates best practices like coding style and design patterns. The tutorial series also discusses advanced features like templates, namespaces, and operator overloading. It illustrates writing and refactoring code by solving problems using C++ features.
C++ Fundamentals Study Guide
Quiz
1. What is the purpose of a function in C++? Functions allow you to encapsulate a block of code that performs a specific task, making your program more modular, reusable, and easier to understand. They help avoid code duplication and promote organization.
2. Explain the difference between parameters and arguments in the context of a function. Parameters are variables declared in the function definition’s parentheses, acting as placeholders for input values. Arguments are the actual values passed into the function when it is called; they are assigned to the parameters.
3. What is a “void” function, and how does it differ from a function with a return type? A “void” function is a function that does not return any value; it performs a task or a series of actions but does not produce a specific output. In contrast, a function with a return type must return a value of the specified type using the return statement.
4. Define “data type” in C++, and give three examples. A data type specifies the kind of value that a variable can hold and the operations that can be performed on it. Examples include int (integers), double (floating-point numbers), and char (characters).
5. What does it mean for C++ to be a “statically typed” language? In C++, being statically typed means that the data type of a variable is known at compile time and cannot be changed during runtime. This allows the compiler to perform type checking and catch errors before the program is executed.
6. Explain the difference between a “signed” and an “unsigned” integer. A signed integer can represent both positive and negative values, while an unsigned integer can only represent non-negative (positive and zero) values. Using an unsigned type effectively doubles the maximum positive value that can be stored compared to a signed type of the same size.
7. What is an “escape sequence” in C++, and give two examples. An escape sequence is a special character combination used to represent characters that are difficult or impossible to type directly. Examples include \n (newline) and \t (horizontal tab).
8. What is the purpose of the bool data type, and what values can it hold? The bool data type represents a boolean value, which can be either true or false. It is commonly used in conditional statements and logical expressions to control program flow.
9. What are “floating-point” data types, and what are the three types available in C++? Floating-point data types are used to represent numbers with fractional parts. The three floating-point types in C++ are float, double, and long double, differing in their precision and memory usage.
10. What are “operators” and “operands” in C++, and give an example. Operators are symbols that perform operations on one or more operands. Operands are the values or variables that the operators act upon. In the expression 5 + x, + is the operator, and 5 and x are the operands.
Quiz Answer Key
Functions allow you to encapsulate a block of code that performs a specific task, making your program more modular, reusable, and easier to understand. They help avoid code duplication and promote organization.
Parameters are variables declared in the function definition’s parentheses, acting as placeholders for input values. Arguments are the actual values passed into the function when it is called; they are assigned to the parameters.
A “void” function is a function that does not return any value; it performs a task or a series of actions but does not produce a specific output. In contrast, a function with a return type must return a value of the specified type using the return statement.
A data type specifies the kind of value that a variable can hold and the operations that can be performed on it. Examples include int (integers), double (floating-point numbers), and char (characters).
In C++, being statically typed means that the data type of a variable is known at compile time and cannot be changed during runtime. This allows the compiler to perform type checking and catch errors before the program is executed.
A signed integer can represent both positive and negative values, while an unsigned integer can only represent non-negative (positive and zero) values. Using an unsigned type effectively doubles the maximum positive value that can be stored compared to a signed type of the same size.
An escape sequence is a special character combination used to represent characters that are difficult or impossible to type directly. Examples include \n (newline) and \t (horizontal tab).
The bool data type represents a boolean value, which can be either true or false. It is commonly used in conditional statements and logical expressions to control program flow.
Floating-point data types are used to represent numbers with fractional parts. The three floating-point types in C++ are float, double, and long double, differing in their precision and memory usage.
Operators are symbols that perform operations on one or more operands. Operands are the values or variables that the operators act upon. In the expression 5 + x, + is the operator, and 5 and x are the operands.
Essay Questions
Discuss the benefits and drawbacks of using statically typed languages like C++. In what scenarios might a dynamically typed language be more appropriate?
Explain the importance of data types in C++, and how the choice of data type can impact memory usage, program performance, and the range of values that can be represented.
Describe the different types of loops available in C++, and provide examples of situations where each type of loop would be most suitable.
Explain the concept of function overloading in C++. What are the benefits of using function overloading, and what are the limitations? Provide examples to illustrate your explanation.
Explain the key principles of object-oriented programming (OOP) and how they are implemented in C++ using classes.
Glossary of Key Terms
Argument: The actual value passed to a function when it is called.
Bit: The smallest unit of data in a computer, representing a binary value of 0 or 1.
Bool: A data type representing a boolean value, either true or false.
Char: A data type representing a single character.
Class: A blueprint for creating objects, defining their data (attributes) and behavior (methods).
Compiler: A program that translates source code written in a high-level language into machine code that can be executed by a computer.
Constructor: A special method within a class that is automatically called when an object of that class is created.
Data Type: Specifies the type of value a variable can hold and the operations that can be performed on it.
Double: A data type representing a double-precision floating-point number.
Escape Sequence: A sequence of characters that represents a special character (e.g., \n for newline).
Expression: A combination of operators and operands that evaluates to a single value.
Float: A data type representing a single-precision floating-point number.
Function: A block of code that performs a specific task.
Integral Data Types: Represents whole numbers, either signed or unsigned (e.g., int, short, long, char).
Long Double: A data type representing an extended precision floating-point number.
Method: A function that is associated with an object or a class.
Namespace: A declarative region that provides a scope to the identifiers (names of types, functions, variables, etc.) inside it.
Object: An instance of a class, containing data and methods.
Operand: A value or variable on which an operator performs an operation.
Operator: A symbol that performs a specific operation.
Overloading: Defining multiple functions with the same name but different parameters.
Parameter: A variable in the function definition that receives an argument value.
Return Type: The data type of the value returned by a function.
Signed Integer: An integer that can represent both positive and negative values.
Static Typing: Type checking is performed at compile time.
String: A sequence of characters.
Templates: Allow functions and classes to operate with generic types.
Unsigned Integer: An integer that can only represent non-negative values.
Void: A keyword indicating that a function does not return a value.
C++ Programming Fundamentals: A Comprehensive Overview
Okay, here’s a detailed briefing document summarizing the key themes and ideas from the provided excerpts from “01.pdf”.
Briefing Document: C++ Programming Fundamentals
I. Overview
This document summarizes excerpts from a series of C++ programming tutorials. The central themes revolve around:
Functions: Defining, calling, and understanding different types of functions (returning values vs. void functions).
Data Types: Introduction to and in-depth exploration of various C++ data types (int, double, char, bool, float), their properties (size, signed/unsigned), and how to work with them.
Control Flow: Using conditional statements (if, else if, else, switch) and loops (for, while, do-while) to control program execution.
Operators: Understanding operators, operator precedence, and how to overload operators for custom classes.
Data Structures: Introduction to the vector container and file input/output operations.
Code Organization: Using namespaces and function templates for better code structure and reusability.
Object-Oriented Programming (OOP): Introduction to classes and objects, including concepts such as constructors, methods, and operator overloading.
II. Key Themes and Ideas
Functions: Building Blocks of ProgramsDefining Functions: The core structure of a function involves a return type, identifier (name), parameters, and a body.
“To summarize we create a function by giving it a return type an identifier parameters and then a body”
Parameters vs. Arguments: Parameters are defined in the function definition, while arguments are the actual values passed when the function is called. The names don’t have to match.
“These here are known as parameters and when we pass in values these are known as arguments they are two separate variables that means they don’t have to be named the same”
Return Values: Functions can return a value of a specific type. This value must be used in the calling program.
“At the end we need to return a value that is of the type that we’re putting as the return type here and then we need to use that value in the calling program”
Void Functions: Functions that perform actions but don’t return a value. Common uses include logging or outputting to the console. They are called by simply stating their name and arguments; there’s no assignment.
“We can actually create functions that don’t return values and those are called void functions they’re void of a return essentially”
“When you have a void function you just call it by itself and you don’t do anything in the calling part of it”
Data Types: Specifying the Kind of DataStatic Typing: C++ is statically typed, meaning variables have a specific data type that is fixed at compile time.
“C++ is what’s known as a statically typed programming language and what that means is that variables such as X in this case has a data type when you declare the variable and it’s always going to store an integer in this case”
Integer Types: int, short, long, long long, and their unsigned counterparts. Size (memory allocation) varies but has minimum guarantees (e.g., int is at least 16 bits). Using unsigned extends the maximum positive value.
Character Type: char is used to store small numbers or individual characters (8 bits). Characters are enclosed in single quotes (e.g., char myChar = ‘A’;).
Boolean Type: bool represents true or false values. Can be implicitly converted to numbers (0 for false, 1 for true).
“This video we are going to be talking about the bull data type bu is short for Boolean which really is just true or false”
Floating-Point Types: float, double, long double are used to represent numbers with decimal points. They use scientific notation internally (significant digits and a multiplier). There are special values like NaN (Not a Number), Infinity, and negative Infinity.
Literals: Ways to represent values of a data type directly in the code. Can be decimal, hexadecimal (prefix 0x), or octal (prefix 0). Floating-point literals can use scientific notation (e.g., 7.7E4).
Controlling Program FlowConditional Statements: if, else if, else are used to execute different blocks of code based on conditions.
Switch Statements: Provide a multi-way branching mechanism based on the value of an integral variable. Limited to exact values.
Loops: for, while, do-while are used to repeat blocks of code.
for loops are typically used when the number of iterations is known beforehand.
while loops are useful for indefinite loops that continue until a condition is met.
do-while loops execute the code block at least once.
break and continue: break exits the innermost loop. continue skips the current iteration and proceeds to the next.
“The break keyword is used to break out of the closest Loop that you’re in”
Operator Precedence: Determines the order in which operators are evaluated.
Operator Overloading: Allows you to redefine the behavior of operators for custom classes.
Data Structures: Organizing DataArrays: Fixed-size, contiguous blocks of memory to store elements of the same type.
Vectors: Dynamic arrays that can grow or shrink in size. They provide methods like push_back (add an element), size (get the number of elements), and indexing (access elements using []).
“The data here is actually copied into this variable here that means any changes we do to the vector inside of this function do not exist inside of main”
File Input/Output: Using fstream (specifically ifstream for input and ofstream for output) to read from and write to files. getline is used to read a line from a file.
Code Organization and ReusabilityNamespaces: Used to group related code and prevent naming conflicts.
Function Templates: Allow you to create generic functions that work with different data types without having to write separate overloads for each type.
“Function templates are a way to tell the compiler that you want to generate these different overloads you’re essentially saying hey compiler make some overloads for me I don’t feel like it and it’s going to do it for you”
Object-Oriented Programming (OOP)Classes and Objects: A class is a blueprint for creating objects. Objects are instances of a class.
“This is known as instantiation it’s a pretty cool word you can use it at the the local hangout spot to pick up chicks just start talking about classes and objects and instantiation and you’ll be like the ladies man all right trust me”
Methods: Functions associated with objects.
Constructors: Special methods that are called when an object is created.
Operator Overloading: Allows you to redefine the behavior of operators for custom classes.
III. Potential Issues/Gotchas
Data Type Sizes: Be aware that the actual size of data types (especially int) can vary depending on the system or compiler. Rely on minimum size guarantees for portability.
Scope: Variables declared within a block (e.g., inside a function or loop) are only accessible within that block.
Infinite Loops: Ensure that loop conditions eventually become false to avoid infinite loops.
Array/Vector Bounds: Be careful not to access elements outside the valid range of an array or vector (e.g., accessing index -1 or an index greater than or equal to the size).
IV. Further Study
The excerpts suggest the following topics for further study:
This briefing doc provides a strong foundation for understanding the C++ language. Good luck with your continued learning!
C++ Functions, Data Types, and Namespaces Explained
FAQ
What is a function in C++, and what are its key components?
In C++, a function is a block of code that performs a specific task. Key components include:
Return Type: Specifies the type of data the function will return (e.g., int, double, void). void means the function does not return a value.
Identifier (Name): The name of the function.
Parameters: Input values the function receives, declared with their types (e.g., double base, int exponent).
Body: The code block within curly braces {} that contains the instructions the function executes.
Return Statement: If the return type is not void, the function must have a return statement to provide a value of the specified type.
What’s the difference between parameters and arguments in the context of functions?
Parameters are variables declared within the function’s parentheses in the function definition (e.g., double base, int exponent). Arguments are the actual values or variables passed into the function when it’s called (e.g., 10, 3, myBase, myExponent). The names of arguments don’t have to match the names of parameters, but their types must be compatible.
What is a void function, and when would you use it?
A void function is a function that does not return a value. You would use it when you want to perform an action or a series of actions (like printing to the console, writing to a file, or modifying data) without needing to calculate and return a specific result.
What are data types in C++, and why are they important?
Data types define the type of data a variable can hold (e.g., integer, floating-point number, character, boolean). C++ is a statically typed language, meaning variables have a fixed data type that’s known at compile time. This offers advantages like:
Knowing what kind of data should be expected, which provides information on how to use this data appropriately
Catching type-related errors during compilation.
Optimizing memory usage because the compiler knows how much memory to allocate for each variable.
More restrictive, as variables can only store data of their declared type.
What is the difference between int, short, long, and long long integral data types?
These are all integer data types, but they differ in the amount of memory they allocate and, therefore, the range of values they can store.
short: Guaranteed to be at least 16 bits.
int: Guaranteed to be at least 16 bits, but typically 32 bits.
long: Guaranteed to be at least 32 bits.
long long: Guaranteed to be at least 64 bits.
The larger the data type, the wider the range of numbers it can represent. You can use sizeof() to determine the size (in bytes) of these types on your system, and <climits> provides macros (e.g., SHRT_MAX, INT_MIN, LLONG_MAX) that define the minimum and maximum values for each type.
How do escape sequences work in C++, and what are some common examples?
Escape sequences are special character combinations, beginning with a backslash \, that represent characters that are difficult or impossible to type directly into a string or character literal. Common examples include:
\n: Newline (moves the cursor to the next line).
\t: Horizontal tab.
\\: Backslash (allows you to include a literal backslash).
\”: Double quote (allows you to include a double quote within a string).
\’: Single quote (allows you to include a single quote within a character literal).
\0: Null terminator (used to mark the end of a C-style string).
What is the bool data type, and how is it used in C++?
The bool data type represents Boolean values, which can be either true or false. It is often used as a flag or indicator to represent the state of a condition. bool values are often used in conditional statements (if, else) and loops to control program flow. Internally, true is often represented by the integer 1, and false by 0.
What are namespaces in C++, and why are they used?
Namespaces are used to organize code and prevent naming conflicts, especially in large projects or when using external libraries. They create a distinct scope for identifiers (like function and variable names).
C++ Programming: An Introductory Tutorial Series
The all-in-one C++ video combines a 100-part video series that introduces the C++ programming language. The goal of the series is to help viewers enjoy programming while gaining a good understanding of the technical details of C++ and programming in general.
Key concepts and features covered in the C++ tutorial series:
Compiled Language C++ is a compiled language, meaning that human-readable code is converted into machine-readable code through compilation and linking.
Object-Oriented and Generic Programming C++ introduced object-oriented programming, which structures code around classes and instances (objects), and generic programming, which uses structures that work with different data types.
Comparison with Other Languages C++ is distinct from C, Java, Python, and JavaScript. While modern languages have object-oriented programming, C++ allows for program optimization but requires more knowledge and can be more complex. C++ is often used for game engines, video editing software, and modeling programs.
Tools For Windows, Embarcadero C++ Builder is recommended, which provides code editing and a compiler, along with debugging and deployment capabilities for various platforms. On a Mac, the terminal can be used with g++, along with a text editor like Visual Studio Code.
Basic Program Structure A basic C++ program includes the iostream library, a main function int main(), and a return statement return 0. The std::cout object is used for outputting text to the console.
Namespaces Using namespace directives (e.g., using namespace std;) can simplify code but may lead to naming conflicts. Using declarations (e.g., using std::cout;) can reduce conflicts by specifically declaring which objects to use.
Variables Variables store values and have a data type (e.g., int slices = 5;). They can be declared and initialized separately.
Output Formatting Complex strings can be created using the << operator, and manipulators like std::endl can insert new lines.
Coding Style Descriptive variable names and adherence to style guides like the C++ Core Guidelines are recommended for better code maintainability.
Functions Functions are reusable blocks of code. The main function is the entry point of a program. Functions can accept arguments and return values.
Strings The string class in C++ is used to manipulate strings. String manipulation includes concatenation and appending.
Data Types The series covers integral types, floating-point types, characters, and strings. Floating-point numbers (float, double, long double) have limited precision.
Constants Different types of constants include literal, symbolic (const), and macro constants.
Control Flow Control flow includes branching (if/else statements, switch statements) and looping (while loops, for loops, do-while loops).
Loops Loops repeat a section of code. While loops, for loops, and do-while loops are common types.
Arrays Arrays are collections of elements of the same type.
Vectors Vectors are similar to arrays but have a dynamic size. Vectors can be expanded using the push_back method.
Collections Key differences exist among arrays, templatized arrays, and vectors, especially in sizing (static vs. dynamic) and how they are passed to functions.
Range-Based For Loops These loops simplify iterating through collections.
Input/Output Streams Input streams bring data into a program, and output streams send data out. Data is often buffered.
File Streams Data can be read from and written to files using ifstream and ofstream objects.
Structs Structs are used to store data and can contain data members and methods.
Classes and Objects Classes define the structure of data, and objects are instances of classes.
Makefiles Makefiles automate the build process, especially for large projects.
The series also mentions that the content is sponsored by Embarcadero C++ Builder, which provides tools for developing and deploying C++ applications across multiple platforms. C++ Builder has features for designing apps, working with databases, debugging, and deploying to various platforms.
C++ Main Function: Program Entry Point and Execution
The C++ tutorial series emphasizes the significance of the main function in a program’s execution. Here’s a breakdown:
Entry Point: The main function serves as the primary entry point; it is the first function that is automatically executed when a C++ program runs. The execution of the program begins at the first line of code inside the main function.
Return Type: The main function has a return type of int (integer). It returns an integer value to indicate whether the program ran successfully. A return value of zero typically means the program executed without errors.
Optional Return: Although the main function has an integer return type, the return statement is technically optional. If it is omitted, the compiler will implicitly insert a return 0; at the end of the function.
Function Definition: The code within the curly braces {} of the main function defines what the function does. This is where the program’s logic is written.
Calling Other Functions: The main function often serves as a starting point from which other functions within the program are called. It can call other functions to perform specific tasks or operations.
Multiple Files: In a multi-file project, the main function typically resides in its own separate file. This file includes the necessary header files for any functions or classes used in the main function.
Namespace std: Usage, Implications, and Best Practices
The C++ tutorial series addresses the use of using namespace std; and its implications. Here’s a breakdown:
Purpose The using namespace std; directive is used to make all items within the standard namespace (std) directly available in your code. This means you don’t have to prefix standard library elements like cout or string with std::.
Naming Conflicts The tutorial cautions that using using namespace std; is generally considered bad practice, especially in larger projects or when including multiple libraries. The reason for this is that it can lead to naming conflicts. If two namespaces (including std) define the same name (e.g., a function or a variable), the compiler will not know which one you intend to use, resulting in an error.
Good Practices
Using declarations: A more selective approach is to use using declarations. Instead of importing the entire std namespace, you can specifically declare which items you want to use directly, like using std::cout;. This reduces the risk of naming conflicts while still making your code more readable.
Explicit prefixing: The most explicit and safest approach is to always prefix standard library elements with std::. This ensures that there is no ambiguity about which namespace an item belongs to.
When to Use While generally discouraged for large projects, the tutorial acknowledges that using using namespace std; may be acceptable for small, simple programs or when first starting out. In these cases, the risk of naming conflicts is low, and it can make the code easier to write and understand.
Embarcadero C++ Builder: Cross-Platform IDE for C++ Development
The C++ tutorial series mentions Embarcadero C++ Builder as a recommended tool, especially for those using Windows. It’s described as an IDE (Integrated Development Environment) that provides everything needed to write C++ applications.
Here’s what the tutorial series says about the C++ Builder:
Capabilities: C++ Builder offers capabilities for designing apps, debugging, and deploying to multiple platforms. Specifically, it supports deployment to Windows, Android, Mac, and iOS.
Community Edition: The tutorial highlights the availability of a Community Edition, which is a free version that you can use if you are earning less than $5,000 a year from your software projects. The Community Edition is a fully featured IDE. The Community Edition has limited use for commercial purposes, meaning that you can build and sell applications until you need to upgrade to the professional version.
Features: C++ Builder includes a visual UI designer with drag-and-drop capabilities for creating platform-specific styling.
Recommendation: The tutorial recommends considering C++ Builder for building and deploying applications, particularly when aiming to deploy to multiple platforms.
C++ Variables: Declaration, Types, and Usage
The C++ tutorial series emphasizes the role and characteristics of variables.
Key aspects of variables in C++ programs:
Purpose: Variables are fundamental for storing values that can be used throughout a program. The main point of variables is to store some value for later use.
Definition: When creating a variable, there are five key pieces: the data type, the identifier, the assignment operator, the value, and the semicolon.
Data Type: When a variable is created in C++, a type must be defined. The data type specifies the kind of value that the variable can hold (e.g., integer, floating-point number, character). C++ is a statically typed language, where variables are assigned a data type at declaration that remains fixed.
Examples of data types include int (integer), double (double-precision floating point), char (character), and others. int restricts variables to whole numbers, while double allows for decimal points.
The data type determines the amount of memory allocated for the variable. The size of an int is typically 32 bits but is guaranteed to be at least 16 bits.
Declaration and Initialization: A variable can be declared (named and typed) and initialized (assigned a value) in separate steps or in a single statement.
Declaration indicates that a variable exists. For example, int slices; declares an integer variable named slices.
Initialization assigns a value to the variable. For example, slices = 5; initializes the slices variable with the value 5.
Combined, a single statement looks like this: int slices = 5;.
Assignment Operator: The = symbol is used to assign a value to a variable.
Literal Values: A literal value is a value that is directly typed into the code. For example, int slices = 5; assigns the literal value 5 to the slices variable.
Expressions: Variables can also be assigned the result of an expression. For example, int slices = 5 + 1; assigns the value 6 to the slices variable.
Variable Assignment: The value of one variable can be assigned to another. For example, int children = slices; copies the value of slices into the children variable. Changing the original variable (slices) after assignment does not affect the value of the copied variable (children).
Outputting Variables: The value of a variable can be displayed on the console using std::cout. For example, std::cout << slices; will print the value of the slices variable. When outputting variables, you can insert them directly into strings. For example, std::cout << “You have ” << slices << ” slices of pizza”;.
Input: Variables can also be assigned a value using user input with std::cin. For example, std::cin >> slices; reads an integer value from the console and stores it in the slices variable.
C++ Programming All-in-One Tutorial Series (10 HOURS!)
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!
A great breakfast sets the tone for the rest of the day, yet too often, we fall into monotonous routines, reaching for the same uninspiring choices. Whether it’s a rushed slice of toast or a bland bowl of cereal, mornings can quickly become predictable. But what if breakfast could be something to look forward to—an experience that excites the senses and fuels the body with real energy? With a few simple tricks and fresh ideas, you can transform your morning meal into something extraordinary.
Breakfast isn’t just about sustenance; it’s a daily opportunity to nourish both body and mind. Studies have shown that a well-balanced breakfast can improve concentration, boost metabolism, and enhance overall well-being. According to Dr. Tim Spector, a professor of genetic epidemiology at King’s College London, “The right breakfast can help regulate blood sugar levels, sustain energy, and even support gut health.” By making small but meaningful changes to your breakfast routine, you can create meals that are not only nutritious but also satisfying and enjoyable. If you’re ready to move beyond the mundane and elevate your breakfast game, this guide is for you. We’ve compiled 43 expert-backed tips that will make your mornings more delicious, efficient, and exciting. From creative cooking techniques to smart shortcuts, these ideas will revolutionize your breakfast experience—so let’s dive in!
1 – Breakfast, but better
A well-prepared breakfast is more than just a meal—it’s a foundation for the day ahead. Research suggests that those who eat a balanced breakfast tend to have better cognitive function and a lower risk of chronic diseases. However, many people stick to the same routine out of habit or convenience. To break this cycle, try incorporating diverse ingredients that offer a mix of protein, fiber, and healthy fats. Swap out refined carbs for whole grains, add nutrient-dense toppings to your meals, and experiment with global breakfast traditions for variety. Small changes can make a big difference. Instead of reaching for processed cereal, consider a bowl of Greek yogurt topped with nuts and fresh berries for a protein-packed start. If you love toast, opt for whole grain with avocado and poached eggs rather than butter and jam. Author and nutritionist Marion Nestle emphasizes, “The key to a good breakfast is balance—protein, fiber, and healthy fats help keep you full and energized.” By prioritizing quality ingredients and mindful preparation, you’ll transform breakfast from a dull obligation into a daily delight.
2 – Try French toast in your slow cooker
If you think French toast is only for rushed stovetop cooking, think again. Using a slow cooker allows you to prepare a warm, indulgent breakfast with minimal effort. By layering slices of bread with an egg-based mixture and letting the slow cooker do the work, you’ll achieve a custardy, flavor-infused dish that’s perfect for a weekend treat or meal prep. Slow cooking also enhances flavors, making every bite rich and satisfying. To take your slow-cooked French toast to the next level, experiment with different bread types—brioche, challah, or whole grain for a heartier option. Infuse the mixture with vanilla, nutmeg, or even a splash of orange zest for added depth. Nutrition expert Dr. Lisa Young recommends using natural sweeteners like honey or maple syrup instead of refined sugar to maintain a balance of flavor and health benefits. Once done, top your creation with fresh fruits, nuts, or even a dollop of Greek yogurt for a wholesome finish.
3 – Use cookie cutters to get the perfect pancake shape
Breakfast should be fun, and one of the easiest ways to bring creativity to the table is by making beautifully shaped pancakes. Whether you’re cooking for kids or just want to brighten your morning, cookie cutters can turn ordinary pancakes into delightful works of art. Using sturdy metal cutters as molds, you can create everything from classic hearts to intricate animal shapes. This technique not only adds visual appeal but also ensures a consistent size and even cooking.
Beyond aesthetics, this method also allows you to experiment with different batters. Thick American-style pancakes hold their shape best, but you can also try oat-based or protein pancakes for a nutritious twist. For an extra touch of flavor, mix ingredients like cinnamon, cocoa powder, or mashed banana into the batter. Food scientist Harold McGee, author of On Food and Cooking, suggests that letting the batter rest for a few minutes before cooking helps develop a fluffier texture. With a few simple tweaks, your pancakes can become a standout breakfast feature.
Conclusion
By making small adjustments to your morning routine, you can completely transform breakfast from a rushed necessity into an enjoyable ritual. Whether it’s rethinking the ingredients you use, leveraging kitchen gadgets like slow cookers, or adding a touch of creativity with fun shapes, each tip brings new life to your first meal of the day. The key is to experiment, adapt, and find what works best for your lifestyle and taste preferences. Breakfast doesn’t have to be boring or repetitive. As food journalist Bee Wilson states in First Bite: How We Learn to Eat, “Our food habits are not fixed—they can be reshaped and improved at any time.” With the right inspiration and techniques, you can create a breakfast experience that is nourishing, delicious, and exciting, setting the perfect tone for the rest of the day.
4 – Bake an egg in half an avocado
Eggs and avocados are a powerhouse combination, packed with protein, healthy fats, and essential vitamins. Baking an egg inside an avocado not only makes for an eye-catching breakfast but also offers a nutrient-dense start to the day. This dish is naturally low in carbs and high in fiber, making it an excellent option for those following a keto or paleo diet. The creamy texture of the avocado pairs beautifully with the richness of the baked egg, creating a balanced and satisfying meal.
To elevate this simple recipe, consider experimenting with toppings that add flavor and texture. A sprinkle of chili flakes brings heat, while crumbled feta or grated Parmesan adds a salty contrast. You can also incorporate smoked salmon for extra protein or drizzle honey over the finished dish for a sweet-savory twist. Nutritionist Dr. Mark Hyman, author of Food: What the Heck Should I Eat?, emphasizes the importance of whole, unprocessed ingredients, stating, “Healthy fats from sources like avocado can support brain function and sustain energy levels throughout the morning.” Serve your baked egg and avocado creation with grilled sourdough or a side salad for a well-rounded breakfast.
5 – Test out eggs in bacon cups
If you love a hearty breakfast but hate the cleanup, eggs in bacon cups are a game-changer. This recipe combines protein-rich eggs with crispy, flavorful bacon, all baked together in a convenient muffin tin. The bacon acts as a savory shell, holding in the eggs and any additional fillings, ensuring that every bite is packed with flavor. Unlike traditional fried breakfasts, this method requires little active cooking time, making it perfect for busy mornings or meal prep.
For an even more gourmet twist, try experimenting with different fillings. Spinach and goat cheese add a Mediterranean touch, while diced bell peppers and cheddar offer a classic American-style combination. Adding a dash of smoked paprika or fresh herbs like chives can enhance the flavor profile. Dr. David Ludwig, an endocrinologist and author of Always Hungry?, notes that “protein-rich breakfasts can help control appetite and prevent overeating later in the day.” Serve these bacon cups with sautéed greens or a slice of toasted baguette for a complete and satisfying meal.
6 – Mix up your usual avocado toast
Avocado toast has become a breakfast staple, but there’s no reason to settle for the same preparation every time. By adding unexpected ingredients or using alternative preparation methods, you can keep this classic dish exciting and full of bold flavors. A simple way to elevate avocado toast is by incorporating umami-rich spreads like Marmite or Vegemite before adding the avocado. These savory additions bring out the natural creaminess of the fruit while providing an extra punch of flavor.
For a more indulgent take, try pairing smashed avocado with crispy chorizo bits and crumbled feta, or mix in finely chopped sun-dried tomatoes for a Mediterranean-inspired twist. If you’re feeling adventurous, fresh berries like strawberries or pomegranate seeds can provide a sweet contrast to the buttery avocado. Food writer Nigella Lawson, in her book At My Table, suggests grilling avocado slices rather than mashing them, which intensifies their flavor and adds a smoky depth. With a little creativity, avocado toast can remain a delicious yet ever-changing part of your breakfast rotation.
Conclusion
Breakfast doesn’t have to be routine when there are endless ways to get creative with simple, wholesome ingredients. Whether it’s baking eggs in an avocado, crafting easy yet elegant bacon cups, or reinventing avocado toast, these ideas ensure that mornings stay exciting and flavorful. Small tweaks to classic dishes can result in a fresh, gourmet experience without adding extra time to your routine.
The key to a great breakfast is variety and balance. As culinary expert Michael Pollan advises in In Defense of Food, “Eat food. Not too much. Mostly plants.” By incorporating high-quality ingredients and experimenting with new textures and flavors, you can make breakfast a meal to look forward to every day.
7 – Upgrade your fried eggs
Fried eggs are a breakfast staple, but a few simple tweaks can turn them from basic to gourmet. Instead of cooking eggs in plain oil or butter, try using flavored oils, infused butters, or even sauces like pesto. The viral pesto egg trend, which took social media by storm, is a perfect example—cooking eggs in pesto infuses them with a rich, herby taste while preventing them from sticking to the pan. Similarly, frying eggs in chili crisp, truffle oil, or even a spoonful of harissa can add a whole new dimension of flavor. For an extra touch of elegance, top your fried eggs with unexpected ingredients. Crumbled feta, sun-dried tomatoes, or a drizzle of balsamic glaze can elevate their taste profile. Chef Yotam Ottolenghi, known for his bold flavor combinations, suggests serving fried eggs over a bed of creamy labneh with za’atar for a Middle Eastern twist. Whether paired with crusty sourdough or served atop a breakfast bowl, these small upgrades can make fried eggs feel like a restaurant-worthy dish.
8 – Use sweet potato for rösti
Sweet potatoes are a nutrient-dense alternative to regular potatoes, offering natural sweetness, vibrant color, and a boost of vitamins A and C. When used in rösti, they create a crispy, slightly caramelized crust that pairs beautifully with both sweet and savory toppings. The key to a perfect sweet potato rösti is squeezing out excess moisture from the grated potatoes before mixing them with eggs and seasonings—this ensures a golden, crispy texture rather than a soggy one. Once baked, the versatility of sweet potato rösti shines through. For a luxurious touch, top with cream cheese and smoked salmon, or add a perfectly fried egg and a spoonful of guacamole for a hearty, nutrient-packed meal. If you prefer a sweeter take, try serving rösti with Greek yogurt, cinnamon, and a drizzle of honey. According to The Flavor Bible by Karen Page and Andrew Dornenburg, “Sweet potatoes pair exceptionally well with tangy, creamy, and smoky flavors,” making them the perfect base for a wide variety of breakfast options.
9 – Give Dutch baby pancakes a try
Dutch baby pancakes may look extravagant, but they require minimal effort and always impress at the breakfast table. These oven-baked pancakes puff up dramatically while cooking, resulting in a crisp, golden exterior with a soft, custardy center. Unlike traditional pancakes, Dutch babies don’t require flipping, making them a foolproof choice for both beginner and seasoned cooks.
While the classic Dutch baby is dusted with powdered sugar and served with a squeeze of lemon, there are endless variations to explore. A savory version topped with crispy bacon, Gruyère cheese, and caramelized onions creates a satisfying brunch dish. On the sweeter side, fresh berries, maple syrup, or even Nutella can make for a decadent treat. As culinary historian Anne Willan notes in The Cookbook Library, “Baked pancakes have been a beloved dish for centuries, combining simplicity with indulgence.” With just a few basic ingredients, you can create a breakfast centerpiece that looks as good as it tastes.
Conclusion
The beauty of breakfast lies in its endless possibilities. Simple ingredients like eggs, sweet potatoes, and pancake batter can be transformed into vibrant, flavorful dishes with just a little creativity. Whether you’re enhancing fried eggs with infused oils, making crispy sweet potato rösti, or baking a showstopping Dutch baby pancake, these small upgrades ensure that breakfast remains exciting and satisfying. As author and food writer Ruth Reichl says, “Pull up a chair. Take a taste. Come join us. Life is so endlessly delicious.” With the right techniques and a willingness to experiment, your morning meal can become the highlight of the day—delicious, nourishing, and worth savoring.
10 – Add breakfast pizza to your repertoire
Pizza for breakfast may sound indulgent, but when done right, it can be a balanced and satisfying meal. A well-made breakfast pizza combines the comfort of a classic pizza with the heartiness of a morning spread. Whether you opt for a homemade dough or a store-bought crust, the key lies in the toppings. Traditional breakfast ingredients like eggs, bacon, hash browns, and mushrooms transform a simple pizza into a morning feast. Baking the pizza at a high temperature ensures a crispy base while keeping the toppings perfectly cooked. For a more gourmet approach, consider experimenting with flavors beyond the usual suspects. Smoked salmon with crème fraîche and dill, ricotta with caramelized onions and arugula, or even a Mediterranean-inspired version with olives, feta, and sun-dried tomatoes can elevate the dish. Renowned chef Alice Waters, in The Art of Simple Food, emphasizes that “good food depends almost entirely on good ingredients,” so selecting high-quality toppings makes all the difference. Serve your breakfast pizza with a fresh side salad or fruit for a well-rounded meal that feels both indulgent and nutritious.
11 – Give green eggs a whirl
A vibrant twist on traditional shakshuka, green eggs offer a nutrient-packed alternative to the usual tomato-based dish. By swapping red sauce for sautéed greens like asparagus, spinach, and cabbage, this breakfast is both visually striking and incredibly wholesome. The key to perfecting this dish lies in gently poaching the eggs among the greens, ensuring the yolks remain runny while the whites are fully set. Adding crumbled feta, chili flakes, or a drizzle of tahini enhances the dish with bold flavors and creamy textures. Green eggs aren’t just delicious—they’re also rich in vitamins, fiber, and antioxidants. According to How Not to Die by Dr. Michael Greger, “leafy greens are among the most nutrient-dense foods available, supporting everything from heart health to brain function.” Pairing them with eggs provides an excellent source of protein, making this dish a powerhouse breakfast. Serve with warm pita bread or a slice of whole-grain toast for a satisfying start to the day.
12 – Use a cupcake tin to bake egg muffins
Egg muffins are the perfect solution for busy mornings, combining convenience with nutrition. These mini frittatas can be prepped in advance and customized with a variety of ingredients, ensuring breakfast never becomes monotonous. By whisking eggs with milk and adding chopped vegetables, meats, or cheese, you create a portable, protein-packed meal that can be stored in the fridge or freezer for later. Baking them in a cupcake tin ensures even cooking and easy portioning.
To elevate your egg muffins, consider using unique flavor combinations. A Mediterranean-inspired mix of sun-dried tomatoes, feta, and spinach brings a tangy, savory touch, while a Southwest-style version with chorizo, bell peppers, and cheddar adds a smoky kick. Culinary expert Mark Bittman, in How to Cook Everything Fast, highlights the value of simple, adaptable recipes, stating, “Cooking should be flexible—use what you have, experiment, and make it your own.” These muffins are an ideal way to reduce food waste while creating a delicious, protein-rich breakfast that fits any schedule.
Conclusion
Breakfast doesn’t have to be repetitive or uninspired. By introducing creative dishes like breakfast pizza, green eggs, and egg muffins, you can transform your morning routine into something exciting and deeply satisfying. These recipes prove that a little innovation in the kitchen can go a long way in making breakfast more enjoyable. As Julia Child famously said, “You don’t have to cook fancy or complicated masterpieces—just good food from fresh ingredients.” With these ideas in your arsenal, you’ll never look at breakfast the same way again. Whether you’re cooking for a crowd or prepping meals ahead of time, these dishes ensure that every morning starts on a delicious note.
13 – Turn leftover pasta into a frittata
Transforming last night’s pasta into a golden, satisfying frittata is a brilliant way to reduce food waste while creating a hearty breakfast. A frittata is essentially an open-faced omelet, and when combined with pasta, it takes on a wonderfully dense and chewy texture. The key to making it successful is to use a mix of eggs, cheese, and seasonings to bind the pasta together before cooking it in a non-stick pan. Parmesan, Pecorino, or even a touch of mozzarella can add depth of flavor, while fresh herbs like basil or parsley provide brightness. For a more elevated version, consider adding sautéed onions, roasted red peppers, or crumbled sausage before setting the frittata in the oven. In Salt, Fat, Acid, Heat, Samin Nosrat emphasizes the importance of balance in cooking: “A truly delicious dish finds harmony between these elements.” Whether served hot or at room temperature, this dish is a wonderful way to breathe new life into leftovers while making breakfast feel both indulgent and practical.
14 – Make a morning mezze
A Middle Eastern–inspired morning mezze is a refreshing departure from the usual breakfast fare. Instead of slaving over a stove, simply assemble a spread of fresh, flavorful ingredients that invite leisurely grazing. Think warm, fluffy flatbreads, creamy labneh, rich hummus, marinated olives, pickled vegetables, and perfectly boiled eggs. The beauty of a mezze-style breakfast lies in its variety—each bite offers something different, from tangy yogurt to briny olives, making it a satisfying and interactive way to start the day. This breakfast style is deeply rooted in Middle Eastern culinary traditions, where meals are often communal and centered around fresh, nourishing ingredients. Claudia Roden, in The New Book of Middle Eastern Food, writes, “The beauty of mezze lies in the pleasure of sharing small, flavorful bites with good company.” Adding extras like spiced chickpeas, grilled halloumi, or a drizzle of pomegranate molasses can take the spread to the next level. Whether for a weekend brunch or a special gathering, a mezze breakfast is a vibrant and fuss-free option that brings people together.
15 – Spice up simple poached eggs
Poached eggs, with their delicate whites and rich, runny yolks, are a breakfast classic, but a few simple additions can elevate them to gourmet status. Infusing the cooking water with aromatics such as bay leaves, garlic, or a splash of vinegar can subtly enhance their flavor. However, one of the best ways to upgrade poached eggs is by taking inspiration from çılbır, a traditional Turkish dish. Placing poached eggs over a bed of thick, garlicky yogurt and drizzling them with chili-infused butter creates a luxurious contrast of creamy, spicy, and tangy flavors.
To take it a step further, sprinkle the dish with sumac, fresh dill, or crumbled feta for added texture and depth. In The Food of the Eastern Mediterranean, Paula Wolfert describes the magic of Eastern spices, stating, “A simple dish can be transformed with the right use of heat and seasoning.” Served with griddled sourdough or warm pita, these poached eggs become the centerpiece of an unforgettable breakfast that feels both comforting and sophisticated.
Conclusion
Breakfast should never be an afterthought, and with a little imagination, even the simplest ingredients can be transformed into something extraordinary. From repurposing pasta into a rich, cheesy frittata to indulging in a Mediterranean-style mezze or spicing up poached eggs with aromatic butter and yogurt, these dishes prove that morning meals can be both effortless and exciting. As celebrated chef and author Nigel Slater puts it, “Good food is the foundation of genuine happiness.” With these inventive breakfast ideas, you can start each day not just with sustenance, but with a moment of culinary delight. Whether you’re cooking for yourself or sharing with loved ones, these tips ensure that breakfast remains a meal to look forward to.
16 – Get a dose of fiber with a breakfast crumble
Starting your day with a fiber-rich breakfast can boost digestion, regulate blood sugar, and keep you full longer. A breakfast crumble made with roasted stone fruits, oats, and dates is an excellent way to achieve this while indulging in a naturally sweet, wholesome dish. Peaches, apricots, and plums release their natural sugars when roasted with a drizzle of honey, creating a warm, caramelized base. Topping them with crunchy granola, fiber-rich dates, and creamy yogurt not only adds texture but also enhances the dish’s nutritional value. To make this breakfast even more nutritious, consider adding flaxseeds or chia seeds for an extra fiber boost. A sprinkle of cinnamon or nutmeg can provide warmth and depth of flavor. According to The Fiber Fueled Cookbook by Dr. Will Bulsiewicz, “Fiber isn’t just important for digestion—it feeds the good bacteria in your gut, which impacts everything from mood to metabolism.” Whether enjoyed warm or chilled, this breakfast crumble offers a delicious and satisfying way to incorporate more fiber into your diet.
17 – Make your own chocolate pastries
Freshly baked chocolate pastries can bring a touch of luxury to your breakfast without the need for a trip to the bakery. Using store-bought puff pastry, you can easily create flaky, buttery croissants filled with rich, melted chocolate. The key to success is rolling the pastry tightly around the chocolate, ensuring it stays enclosed while baking. A quick egg wash adds a glossy finish, while baking at the right temperature guarantees crisp layers and a golden-brown exterior. For a gourmet twist, consider using dark chocolate or a hazelnut spread instead of chocolate chips. A sprinkle of sea salt on top can enhance the sweetness and balance the flavors. As Julia Child once said, “A party without cake is just a meeting,” and the same could be said about breakfast without pastries. Pair these homemade delights with a cup of coffee or a glass of freshly squeezed orange juice for a truly indulgent start to the day.
18 – Cook bacon in the microwave
For those who crave crispy bacon but dislike the mess and time involved in pan-frying, the microwave offers a surprisingly effective alternative. Cooking bacon this way not only reduces splatter but also ensures even crisping in just a few minutes. The trick is to layer the bacon between paper towels, which absorb excess grease while allowing the bacon to cook evenly. This method is particularly useful for busy mornings when time is short but the craving for a hearty breakfast is strong.
While purists may argue that bacon should only be cooked in a pan or oven, modern kitchen hacks like this offer convenience without sacrificing texture. In The Food Lab, J. Kenji López-Alt notes, “Cooking is about achieving the best results with the tools at hand.” Using the microwave for bacon saves time and effort, making it an ideal solution for quick breakfasts. Serve your perfectly crisp bacon alongside eggs, toast, or even crumbled over a salad for a versatile addition to any meal.
Conclusion
A great breakfast doesn’t have to be complicated—it just requires a little creativity and the right techniques. Whether it’s a fiber-packed fruit crumble, homemade chocolate pastries, or perfectly crisp bacon cooked in minutes, these simple yet effective tips help transform your morning routine. As culinary expert Yotam Ottolenghi states in Plenty, “Breakfast is an opportunity to start the day with something beautiful.” By incorporating these easy upgrades into your routine, you ensure that every morning begins on a delicious and satisfying note.
19 – Try your hand at one-pan shakshuka
Shakshuka is a dish that blends simplicity with bold flavors, making it a breakfast staple in the Middle East and North Africa. It consists of poached eggs nestled in a rich, spiced tomato sauce, all cooked in a single pan for minimal cleanup. The combination of onions, garlic, and paprika enhances the depth of flavor, while the tomatoes create a tangy and slightly sweet base. The key to perfecting shakshuka lies in simmering the sauce until it thickens, ensuring the eggs cook gently in their wells without becoming overdone.
For an even heartier version, try adding bell peppers, crumbled feta, or spiced merguez sausage. Serve it with warm pita, crusty sourdough, or even a sprinkle of za’atar for an extra layer of complexity. Yotam Ottolenghi, in his book Jerusalem, describes shakshuka as “a dish of warmth and comfort, best shared straight from the pan.” Whether you’re serving guests or just treating yourself, shakshuka is a vibrant and nourishing way to start the day.
20 – Batch-cook breakfast muffins
For those with busy mornings, batch-cooking breakfast muffins is a game-changer. These versatile, grab-and-go treats can be prepared in advance, saving time without compromising on nutrition. A well-balanced breakfast muffin can be packed with protein, fiber, and healthy fats to keep you full and energized. Options range from savory versions with cheese, herbs, and vegetables to sweet ones with berries, nuts, and seeds.
To keep things interesting, experiment with different flour bases like almond or oat flour for added nutrients. You can also incorporate flaxseeds or chia seeds for a fiber boost. In The Joy of Cooking, Irma S. Rombauer emphasizes that “preparation is the key to stress-free meals.” With a batch of breakfast muffins ready to go, you’ll have a nutritious start to the day, even on the busiest mornings.
21 – Try a one-pan full English wonder
A full English breakfast is a beloved classic, but it can often involve multiple pans and a pile of dishes. By cooking everything in a single pan, you streamline the process while allowing the flavors to meld beautifully. Start by frying the heartier components—potatoes and sausages—before adding mushrooms, bacon, and eggs. Letting everything cook together ensures that each bite is infused with rich, savory flavors.
For a gourmet twist, swap regular sausages for black pudding or add cherry tomatoes for a burst of sweetness. A sprinkle of fresh herbs like thyme or chives can elevate the dish even further. Food writer Nigel Slater once remarked, “A good breakfast is the foundation of a happy day,” and a one-pan full English delivers that satisfaction with minimal effort. Serve with thick, buttery toast and your favorite sauce for a hearty, comforting start to the morning.
Conclusion
A great breakfast doesn’t need to be time-consuming or complicated. With a few clever techniques, you can enjoy rich, flavorful dishes like shakshuka, breakfast muffins, or a simplified full English, all with minimal effort. These methods not only save time but also ensure that every morning meal is both satisfying and stress-free.
As The Breakfast Book by Marion Cunningham suggests, “Breakfast should be something to look forward to, not just another task to complete.” By incorporating these simple yet delicious ideas into your routine, you can turn every morning into a moment of indulgence and nourishment.
22 – Swap toast for potato
If you’re tired of the usual toast routine, swapping it out for a crispy, golden potato alternative can transform your breakfast experience. Potato waffles provide the perfect base for creamy smashed avocado and a runny fried egg, offering a delightful contrast of textures. The crispiness of the potato complements the smoothness of the avocado, while the egg yolk adds a luxurious richness. Not only does this swap enhance flavor, but it also introduces a more filling and satisfying alternative to traditional bread. For those craving something more indulgent, consider a breakfast sandwich where hash browns replace the usual English muffin. Layering a perfectly fried egg, crispy bacon, and gooey melted cheese between two crispy hash browns creates a meal that feels like a special treat. As James Beard, the legendary chef and food writer, once said, “Good food is very often, even most often, simple food.” With just a few clever swaps, you can reinvent your breakfast while keeping it easy and delicious.
23 – Prep granola pots ahead of time
When mornings are rushed, having a ready-to-go breakfast can make all the difference. Granola pots are a fantastic solution, combining nutrition, convenience, and flavor in a single jar. The beauty of granola pots lies in their versatility—layering Greek yogurt with crunchy granola and fresh fruit provides a well-balanced meal packed with protein, fiber, and vitamins. A drizzle of honey or a sprinkle of flaxseeds can enhance the nutritional value, offering sustained energy throughout the morning. Making these pots in advance means you always have a quick breakfast option on hand. Store them in mason jars in the fridge for up to three days, ensuring a stress-free start to your mornings. As Michael Pollan writes in Food Rules, “Eat food. Not too much. Mostly plants.” By incorporating fruits, nuts, and yogurt into your breakfast routine, you create a meal that’s both wholesome and satisfying.
24 – Bake banana bread with a kick
Banana bread is a beloved classic, but adding a bold twist can make it even more exciting. One simple way to elevate your banana bread is by incorporating a shot of espresso into the batter. The deep, roasted flavors of coffee pair beautifully with the natural sweetness of ripe bananas, creating a breakfast treat that offers both comfort and an energizing boost. This twist not only enhances the taste but also provides a mild caffeine kick to help start your day.
To maintain moisture and richness throughout the week, store banana bread in an airtight container and gently reheat slices before serving. For extra indulgence, try spreading a little almond butter or cream cheese on top. As food historian Bee Wilson notes in Consider the Fork, “The way we cook and eat is shaped by history, but also by innovation.” By adding a new dimension to a traditional recipe, you can keep breakfast exciting and satisfying day after day.
Conclusion
With a little creativity, breakfast can be more than just a routine meal—it can be an opportunity to enjoy new textures, flavors, and nutrients. Whether it’s swapping toast for crispy potatoes, preparing nutritious granola pots in advance, or giving banana bread an energizing twist, these simple changes can have a big impact on your morning satisfaction. As culinary expert Marion Nestle reminds us in What to Eat, “The best meals are those that nourish both body and soul.” By incorporating these inventive yet practical breakfast ideas, you set the tone for a more enjoyable and fulfilling day, proving that a great morning meal doesn’t have to be complicated.
25 – Experiment with two-ingredient pancakes
Pancakes don’t have to be complicated to be delicious. If you’re looking for a gluten-free or low-carb option, two-ingredient pancakes made with just bananas and eggs are a fantastic alternative. The natural sweetness of ripe bananas eliminates the need for added sugar, while eggs provide structure and protein. Simply mash a banana, whisk in an egg, and cook small dollops of the batter in a non-stick pan. These pancakes turn out soft, slightly caramelized, and full of flavor.
While they may be more delicate than traditional pancakes, the right toppings can take them to the next level. A dollop of Greek yogurt, a sprinkle of cinnamon, or a handful of berries can enhance both taste and nutrition. Food scientist Harold McGee, in On Food and Cooking, explains that the simplest ingredients often produce the best results when combined correctly. This minimalist approach proves that great breakfasts don’t have to be time-consuming or complicated.
26 – Use leftover fruit in pancake batter
One of the best ways to make pancakes healthier and more flavorful is by incorporating fresh fruit directly into the batter. Whether it’s overripe bananas, diced apples, or a handful of berries, these natural additions infuse pancakes with sweetness and moisture, eliminating the need for refined sugar. Blueberries add a juicy pop, while apples provide a subtle crunch—each fruit brings its own unique texture and depth of flavor.
Another great way to use up leftover fruit is by making a simple compote. Simmer chopped fruit with a splash of water and a drizzle of honey until it breaks down into a thick, syrupy mixture. Served over warm pancakes with a spoonful of creamy Greek yogurt and a sprinkle of nuts, this combination transforms breakfast into a wholesome, restaurant-quality experience. As chef and food writer Alice Waters once said, “Let things taste of what they are.” By celebrating the natural sweetness of fruit, you create a breakfast that is both nourishing and delicious.
27 – Make your own fast food classic
The convenience of a fast-food breakfast sandwich is undeniable, but making your own at home allows for better ingredients, fresher flavors, and a healthier take on the classic. A homemade breakfast muffin starts with a toasted English muffin layered with a fried egg, crispy bacon or sausage, and a slice of melty American cheese. This simple yet satisfying combination delivers the perfect balance of flavors—savory, creamy, and slightly crispy in every bite.
Beyond taste, making breakfast sandwiches at home means you can customize them to suit your preferences. Swap regular bacon for turkey bacon, use whole-grain muffins for added fiber, or add avocado for a nutrient boost. Pair your sandwich with a glass of freshly squeezed orange juice, and you have a balanced meal that fuels your morning without the excess salt and preservatives found in fast food. As Michael Pollan suggests in In Defense of Food, “Eat food, not too much, mostly plants.” Making your own version ensures that every bite is wholesome and made with care.
Conclusion
Breakfast doesn’t have to be repetitive or overly complex to be enjoyable. Whether you’re whipping up two-ingredient pancakes, making use of leftover fruit, or crafting your own fast-food favorite, small tweaks can bring excitement and better nutrition to your morning routine. These simple yet delicious options ensure that your first meal of the day is both satisfying and health-conscious.
As Julia Child once said, “You don’t have to cook fancy or complicated masterpieces—just good food from fresh ingredients.” By experimenting with these creative breakfast ideas, you can turn ordinary mornings into something special while making the most of what’s already in your kitchen.
28 – Posh up your porridge
Porridge is a powerhouse breakfast packed with fiber and slow-releasing carbohydrates, but that doesn’t mean it has to be boring. Instead of the usual sugar or honey, elevate your bowl with creative and indulgent toppings. Poached pears drizzled with maple syrup, caramelized bananas, or even a spoonful of nut butter can transform a simple bowl of oats into a gourmet meal. A dash of warming spices like cinnamon, nutmeg, or cardamom adds extra depth, while a sprinkle of cacao nibs or dark chocolate shavings can make your breakfast feel like dessert.
For a more exotic twist, try a tropical porridge with coconut milk, diced mango, and toasted coconut flakes. Alternatively, give your oats a protein boost by stirring in Greek yogurt or a scoop of protein powder. By experimenting with different textures and flavors, your porridge can be both delicious and nutritious, ensuring you never get tired of this breakfast staple.
29 – Try on-the-go breakfast bars
When mornings are hectic, having a homemade breakfast bar on hand can be a lifesaver. Store-bought options are often packed with sugar and preservatives, but making your own is surprisingly easy and allows you to control the ingredients. A simple recipe involves mixing oats with mashed banana, honey, and peanut butter, then baking until set. For extra nutrition, throw in chia seeds, flaxseeds, or a handful of nuts.
For those who prefer no-bake options, energy bars made with dates, almonds, and cocoa powder are a great alternative. Simply blend the ingredients, press into a pan, and refrigerate until firm. These bars can be stored in an airtight container for a week or frozen for longer-lasting convenience. Whether you prefer fruity, nutty, or chocolatey flavors, having a healthy, homemade grab-and-go breakfast ensures you start your day on the right note.
30 – Prep overnight oats
Overnight oats are the ultimate make-ahead breakfast, requiring minimal effort while delivering maximum flavor and nutrition. By soaking oats overnight in liquid—be it almond milk, yogurt, or even fruit juice—you allow them to soften and absorb all the delicious flavors. The result? A creamy, ready-to-eat meal in the morning that requires no cooking at all.
The beauty of overnight oats lies in their versatility. For a classic version, mix in cinnamon, honey, and chopped apples. If you’re in the mood for something indulgent, try a chocolate peanut butter combination by adding cocoa powder and a dollop of peanut butter. Fresh fruit, nuts, and seeds make excellent toppings, providing a mix of textures and essential nutrients. With endless possibilities, overnight oats are a game-changer for those who want a quick yet satisfying breakfast.
Conclusion
By incorporating these small yet effective changes into your morning routine, you can turn ordinary breakfasts into extraordinary meals. Whether you’re upgrading a humble bowl of porridge, preparing nutritious homemade bars, or letting your oats soak overnight for a hassle-free start, these tips ensure you never have to settle for a bland or uninspiring breakfast again. Not only do these ideas enhance flavor and variety, but they also support a healthier lifestyle by reducing processed ingredients and promoting balanced nutrition. With a little planning and creativity, you can enjoy a morning meal that fuels your day with energy and satisfaction.
31 – Cheat your way to flawless hollandaise
Hollandaise doesn’t have to be a hassle. Simply whisk together two egg yolks, a small splash of both white wine vinegar and ice-cold water, and a pinch of salt in a metal bowl that can fit over a small pan of water. With the water barely simmering, whisk continuously until the consistency is pale and thick (around three to five minutes). Remove from the heat and whisk in 5oz cubed unsalted butter, until the sauce is creamy and runny. Season with salt and pepper, a squeeze of lemon juice, and a sprinkling of cayenne pepper.
32 – Master the art of perfect poached eggs
Haven’t cracked the art of perfect poached eggs yet? There are a few hacks out there, but here’s the simplest: add enough cold water to a pan so that the egg will be only half submerged, then add a dash of lemon juice. Crack the egg over a sieve first to release its runniest parts, place it in a small metal bowl, then add to the pan and cover. Simmer on high heat for three minutes. The result? Delicious eggs that are soft and runny every single time.
33 – Try baking your bacon
Baking bacon is a great fuss-free idea (and a delicious way to achieve perfectly crispy rashers). Line a baking tray with foil and cook at 400°F for around 15 minutes, keeping an eye on the bacon towards the end in case it burns. Pop a few rashers in between two slices of buttered bread and finish with a squirt of ketchup for the ultimate bacon sandwich.
34 – Blend sweet and savory
Don’t be afraid to mix things up when it comes to early morning flavors – you want to awaken those taste buds, after all. Maple syrup and bacon is a classic combo for a reason and works brilliantly on both waffles and pancakes. If you’re after something lighter, try apple slices spread with peanut butter and finished with a drizzle of honey for a healthy and surprisingly tasty morning mouthful. A scant sprinkling of salt, meanwhile, might be just the thing to turn your bowl of porridge from mediocre to moreish.
35 – Try microwaved scrambled eggs
There are plenty of egg-based microwave marvels you can whip up for breakfast. For what some claim is the perfect way to make scrambled eggs (purists, look away), whisk eggs with a dash of milk and a little seasoning, then cook for a minute and a half on high, stirring midway. The result? Soft, fluffy eggs with minimal cleanup. Serve over buttery wholemeal toast for a filling morning meal.
36 – Have fish at breakfast for extra nutrients
Eating fish at breakfast is a great way to fill up on both omega-3 fatty acids – which studies suggest could help boost brain health – and protein, which keeps you fuller longer. A smoked salmon and cream cheese bagel is a luxurious yet effortless option, while grilled mackerel served with soda bread, poached eggs, and fresh chives makes for a nutritious and satisfying morning feast.
Bibliography on Cooking Breakfast
If you’re looking to explore breakfast recipes, techniques, and inspirations further, here are some recommended books, websites, and articles on cooking breakfast:
Books
The Breakfast Bible – Seb Emina & Malcolm Eggs A comprehensive guide to breakfast culture, history, and recipes from around the world.
Big Bad Breakfast: The Most Important Book of the Day – John Currence A chef’s take on bold, indulgent, and classic Southern-style breakfast dishes.
Egg: A Culinary Exploration of the World’s Most Versatile Ingredient – Michael Ruhlman An in-depth look at eggs and their role in cooking, including techniques for breakfast dishes.
Brunch at Bobby’s: 140 Recipes for the Best Part of the Weekend – Bobby Flay Celebrity chef Bobby Flay shares brunch recipes, from eggs to cocktails.
The Art of Breakfast: How to Bring B&B Entertaining Home – Dana Moos A guide to creating gourmet breakfast and brunch meals inspired by bed-and-breakfast hospitality.
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!