Common Collector BJT Amplifier in Proteus ISIS
Hi Mentees, Welcome to a new tutorial at The Engineering Projects. Today You will unearth about Common Collector bipolar Junction Transistor Amplifiers. Before this, we learnt about two types of Configurations of Transistors named Common Emitter BJT Amplifiers and Common Base BJT Amplifiers.
In this tutorial We'll discuss about:
- Introduction of Common Collector BJT Amplifier.
- Basic Concepts for the Common Collector BJT Amplifiers.
- Implementation of Common Collector BJT Amplifiers in Proteus ISIS.
- Characteristics and advantages of Common Collector BJT Amplifiers.
So that, you can get the best understanding about the topic and its practical implementation.
Introduction
1st of all, We'll have a brief definition of the Common Collector Amplifier:
" A type of Bipolar Junction Transistor Amplifier is called Common Collector BJT Amplifiers in which Collector is common to both Base, Base region is used for input and emitter is used to take the output of the Amplifier."
It is one of the Configuration of the Transistor and is used in many kinds of circuits due to its efficiency. Other two Configurations are;
- Common Base BJT Amplifiers.
- Common Emitter BJT Amplifiers.
All of them acquire their Own Construction, characteristics and advantages as we as disadvantages. Common Collectors are also called as
Emitter follower Configuration as the emitter voltage follows the base voltage.
Basic Concepts:
It is Always useful to get core information about the circuit before its Implementation. Let's see what a Common Collector amplifiers is.
Type of transistor:
Recall that the are two types of Transistors i.e, 1. NPN 2.PNP. the Transistor we are using NPN transistor for our Experiment because in this type, the electrons are majority carries that have more mobility than holes ( majority charge carriers in PNP transistors) therefore, we get quick and easy output due to best electron flow.
Current Gain:
The current gain of this type of amplifier is also taken as the division of the Emitter current with the base current and mathematically it is stated as:
Current Gain = Emitter current/Base Current
? = IE/IB = ß + 1
Voltage Gain :
Voltage Gain of Common Collector BJT Amplifier is considered to be the unity, i.e. 1 and is obtained by the formula given below:
Voltage Gain=Vout/Vin
where in Common Collector amplifier we give the input to Base and take the output from the emitter of the transistor.
Emitter Current:
in this Configuration the Emitter current is taken as the sum of base current and collector current.
consequently, we say
Ie=Ib+Ic
we can use this equation in others ways as,
Ib=Ie-Ic
Ic=Ie-Ib
we can also say that the collector current is approximately equal to Emitter current because base is very thin region and passes a minute amount of current through it.
Implementation of Common Collector BJT Amplifier in Proteus ISIS
At the instance, we will test the circuit given in the circuit diagram in Proteus. the material for the Circuit is given below.
Material Required:
- Transistor (2N1711)
- Capacitor
- Resistor
- Vsine
- Oscilloscope
- Ground
- Take 1st four components from the "Pick device" library presented at the left corner of the screen.
- Set them at the working area according to the circuit diagram.
- Add the ground terminal by left clicking the screen >Go to Place>Terminal>Ground and add the ground Terminal.
NOTE: You can also connect just one Ground terminal to the circuit if you connect the Circuit with a wire at the bottom.
Now, the Circuit will look like this:
- Add the DC source from "Generation Mode" to just above the circuit.
Now, We need an output device to examine the output. Therefore, We'll use Oscilloscope. Choose it from "Virtual Instrument mode".
- Set the Oscilloscope just aside the circuit and Connect Channel A with input (Base) and the Channel B with the output ( Emitter).
Before Starting the simulation, I am going to change the values of the Components I used because the default values will not give us the required Output.
- we will use the 120V for the DC Power source.
- One can clearly examine that the Values of the Components are given according to the table given below:
Components |
Values |
Resistor R1 |
10ohm |
Resistor R2 |
100ohm |
Resistor R3 |
20ohm |
Resistor R4 |
100kohm |
VSine |
Amplitude=220, Frequency=1000 |
Capacitor 1 |
50m |
Capacitor 2 |
2m |
Oscilloscope |
Channel 5V, Channel B=5V, Time=0.2mS-1 |
- After setting the values you can change the value of Oscilloscope to get the required output.
NOTE: The amplifiers are sensitive to the temperature and the type of transistor used, hence their must be the practice to get the best output.
Characteristics
- The input Resistance of Common Collector Amplifiers is high.
- The power gain of this kind of amplifiers is medium.
- It has low output resistance.
- It has non-inverting effect (opposite to other two Configuration that gives the inversion of the wave).
- It has zero voltage gain.
Advantages of Common Collector BJT Amplifiers
- It is useful for the circuits where the high impedance is required.
- It is mostly used as voltage buffers as the voltage gain is unity.
- The Common Collector configuration is used in the Circuit where the engineers want the high current gain.
- Due to its high current gain, it is applied in circuits to drive heavy loads.
- We use it for voltage translation stage.
NOTE: Sometimes, It becomes the disadvantage of the Common Collector bipolar Junction Transistor Amplifier that they have no voltage Gain.
Summary:
Today, we ascertained the Basic Common Collector BJT Amplifiers, learnt some Concepts about it, saw the Implementation in Proteus ISIS, saw some characteristics and found the advantages of the Common Collector Configuration.
Common Emitter BJT Amplifier in Proteus
Hi Learners, I hope you are doing good. This lesson is about implementation of one of the types of Amplifiers i.e,
Common Emitter BJT Amplifier. But, prior to this, we'll revise some basic concepts so that it will be easy for you to understand the roots of the Experiment.
We'll talk about:
- What are Common Emitter Bi-Junction Transistors.
- Concepts of Common Emitter Bi-Junction Transistors.
- Implementation of Common Emitter BJT Amplifiers in Proteus ISIS.
- Why we use Common Emitter BJT in Amplifiers.
What are Common Emitter Bi-Junction Transistors
There are three types of Configurations of a transistor named:
- Common Emitter Configuration
- Common Base Configuration
- Common Collector Configuration
We chose the Common Emitter Configuration due to its suitability (You will learn the reason).
We can
Define Basic Common Emitter BJT Amplifier as:
"A type of amplifier circuit made by a Bi-Polar junction Transistor that uses NPN BJT Transistor, inverts the voltage output wave at 180 degree and is the one from the three basic BJT amplifier Configuration."
Recall that
A Transistor is made by combining two diodes in required manner. Hence, It there are two types of Transistors:
- NPN configuration.
- PNP Configuration.
Here N is the symbol for Negative doping and P is the symbol for positive doping.
Concepts of Common Emitter Bi-Junction Transistors
At this instance We'll look at some basic concepts, on the basis of which we chose these Components along with the values of Components of amplifier.
Current gain:
In BJT Amplifiers, current gain is the ratio of change in collector current to the change in the current of base.
mathematically, Current Gain= Change in collector current/Change in Base Current
ß=?Ic/?Ib
At the same token,
Voltage Gain:
The Voltage Gain of an amplifier is the product two Quantities. One is the ratio of output resistance of the collector to the input resistor of the base, and the other is the current gain.
Voltage Gain=ß(Rc/Rb)
During the Practical work we take AC output voltage from collector with respect to emitter and the Output of Amplifier is taken from Collector. On the other hand, the input is given to the base terminal.
It is obvious to notice that the emitter is Common to Base and Collector. It consist of Voltage divider biasing, hence one of the basic part of circuit is consist of two resistors so that their mid-point is used for supply Base Bias voltage. One more importance point to remember is gain is different from one transistor to the other.
Biasing:
Biasing is a technique to add the Battery in a circuit. It is important in Electronic devices because it establishes the correct operating point of the Transistor amplifier when it is ready to receive the signal from input and hence the plays an important role in reducing the distortion in the output.
If we look at the characteristics then we come to know that Common Emitter BJT Amplifiers has high voltage gain, the current gain is medium and the circuit has a high power gain.
Implementation of Common Emitter BJT Amplifiers in Proteus ISIS
For the practical verification of the circuit It is always Advisable to Perform it at any simulation software. Hence open Your Proteus ISIS.
Components Required:
- NPN transistor (2N171) .
- Vsine
- Capacitor
- Resistor
- DC Power source
- ground Terminal
- Oscilloscope
Procedure:
- Choose 1st four Components from the Pick Library "P" one by one by writing their name in it.
- Collect the DC power supply from "Generator mood" present on the left most tab.
- To get the Ground terminal, left Click on the working screen and go to Place>Terminal>Ground and fix it on the screen.
- Oscilloscope is present in the "Virtual Instrument Mood" on the same tab.
- Once you have chosen all the required Device then set them one by one on the Working area according to the Picture given below and connect them with the help of wires.
- At the Instance we will change the values of some devices So I have made a table for this:
-
Components |
Values |
Resistor R1 |
60ohm |
Resistor R2 |
500ohm |
Resistor R3 |
1000ohm |
Resistor R4 |
2000ohm |
Resistor R5 |
100ohm |
Oscilloscope |
A=20V, B=2V |
Vsine |
Frequency=1000Hz, Amplitude=110V |
DC source |
10V |
After substituting the value we get the prepared circuit for the amplifier as:
It seems that all the things are ready. Once you play the simulation then you can change its values and You will acquire the following output.
- Select the Current probe from the left most bar and connect them in the circuit one with the Base wire and the other with the collector.
One can find the current gain by simply putting the values in the formulas given in the concepts portion.
here,
Current gain=6.2*10-12/6.1
=1.01*10-9
as it is a ratio, hence has no unit.
At the same token,
Voltage gain=1.01*10-9*(500/2000)
=2.5*10-10
NOTE: The Gain is vary from transistor to transistor and the temperature is also an important feature. Therefore, the gain is always unpredictable.
- We got the required output in the Proteus ISIS as required.
let's find out why we used this for our experiment.
Why we use BJT in Amplifiers
Common Emitter BJT Amplifiers are important in the World of Electronics. One can get the idea of their influence by the following points:
- These Amplifiers are used in low frequency voltage amplifier.
- The are useful because of their high power gain with medium voltage and current gain hence they are cheap.
- The output impedance is high.
- It has inverting effect so can be used in the different appliances for different purposes.
In today's tutorial, We learnt what is Common Emitter BJT amplifiers, some basic concepts along with the simulation in the Proteus ISIS. We also saw why these Amplifiers are used in the real life.
The circuit and the output may vary for other circuits but don't worry about that because it is a very sensitive circuit.
Common Base BJT Amplifier in Proteus
Hi mentees, Welcome to
The Engineering Projects. If you are seeking for the Practical Implementation of
Common Base bipolar Junction Transistor amplifier then you clicked at the best website because we'll cover the basic concepts and the procedure step by step.
So, Lets start the learning.
What is Common Base BJT Amplifier?
The precise definition of the Common Base BJT Amplifier is:
"The type of Bipolar Junction Transistor Amplifiers in which Base is Common to both emitter and Collector and Current gain is taken from the Base is called Common Base bipolar Junction Transistor Amplifiers."
Recall that a transistor has three regions i.e, Base, Collector and Emitter. Hence we design our Circuit in such a way that we get the output of current from the base and get the best current gain.
Basic Concepts:
Some Important Concepts should be kept in mind so that it will become easy and interesting to Design the Circuit.
Current gain:
" The Current gain of Common base Amplifier is equal to the ratio of Current in the Collector to the Current in the Base provided by the constant voltage of base to collector."
Mathematically,
Current gain=Collector Current/Base Current
ß=Ic/Ib
Voltage Gain:
"T
he Voltage gain of the Common Base amplifier is obtain when we divide the Voltage of Collector to the voltage of emitter."
mathematically,
Voltage Gain=Voltage of Collector/Voltage of Emitter
Av=Vc/Ve
Type of Transistor:
In the Common Base amplifiers, we use the NPN transistor because in this way we get the require output more easily. In NPN transistors, majority is the electrons. The mobility of electrons is better than holes (in PNP Transistors) so they are faster.
Biasing:
Biasing is a technique to add the Battery in a circuit. It is important in Electronic devices because it establishes the correct operating point of the Transistor amplifier when it is ready to receive the signal from input and hence the plays an important role in reducing the distortion in the output.
Common base MUST correctly Biased so that the base-emitter junction will remain forward Bias.
Now, Let's move towards the practical implementation.
Implementing Common Base BJT Amplifier in Proteus ISIS
To Perform the experiment. we need the Proteus ISIS then follow the steps:
Material Require:
- Transistor (2N1711)
- Capacitor
- Alternating Current Source (Vsine)
- Resistor
- Oscilloscope
- Ground.
- Open Your Proteus software in the PC.
- Seek the Pick Library "P" button and write the name of 1st four Components one by one and select them.
- Place the current components on the working area.
- Acquire the Oscilloscope from the "Virtual Instruments mode" from the left most area and fix it just above the circuit.
- You can obtain the Ground Terminal by left click on the screen>Place>Terminal>Ground or just search it in the "Terminal mode".
- Connect all the Components through wires. The circuit looks like the image given below:
- At this instance , Change the name and values of resistors one by one by double clicking them. In this way, the circuit will work Perfectly.
- I labelled all the Resistors with different names and changed the values according to the need.
- At the same token, the name of Capacitor, battery cells and their values are also changed according to the table given below:
Components |
Values |
Resistor R1 |
400ohm |
Resistor R2 |
30ohm |
Resistor R3 |
100ohm |
Resistor R4 |
200ohm |
BAT |
50 |
BAT 1 |
200 |
CIN |
2mF |
COUT |
60uF |
Oscilloscope |
Channel A=20V, Channel B=20V, time=0.5m-1 |
VSine |
Amplitude 220V, Frequency=1000 |
- Set all the values according to table.
- Once the values are selected (except Oscilloscope) just Pop the Play button.
- You can see an Oscilloscope screen showing the waves.
- Turn of the Channel C,D to avoid distraction.
- Set the values of Oscilloscope by matching with the table.
- You will get the output just like shown in the following image:
The Yellow wave (channel A) indicates the input wave were as the Blue Wave (Channel B) indicates the output ( Amplified) wave.
Hence by If we choose the Components and there value carefully, we get the best output.
Lets Calculate the Current gain then Voltage Gain.
I am using the previously Described precepts to calculate the Quantities:
- Connect the DC Ammeter from the "Generation Mode" and Connect one with the Base of transistor and one with the Collector.
- When we play the Simulation then we get the following Output:
Applying the values into the formula we get,
ß =-1.43/-0.07
=20.4
As it's a ratio so it doesn't have any unit.
Moving towards the Voltage Gain,
- Take the "DC Voltmeter" from the same Portion and connect one Voltmeter with CIN capacitor and one with the COUT Capacitor. Note than the Voltmeter is always Connected in parallel to the required Components.
At the moment, When we start the simulation, we get the following output:
Applying these Values for Av,
Av=53.1/3.75
=14.16
So that the required Quantities are obtained.
Characteristics of Common Base BJT Amplifiers:
- It has High Voltage Gain.
- The Current Gain of Common Base BJT Amplifiers is Medium.
- We get High power Gain in this type of Amplifier.
- Common Base Amplifier does not have any reversal effect between input and output waves.
- The Input and Output resistance of the Common Base Amplifier is Medium.
Advantages:
- We Get the inverted output wave that may be useful in many electronic devices.
- The Input Impedance is Low.
- It is useful due to its high power gain.
- The output Impedance is High for Common Base Bipolar Junction Transistor Amplifiers.
- The Output Impedance is high.
- When we need Impedance matching then CB Amplifiers are useful because we can control the input Impedance.
- It Provides the constant Current Gain therefore can be used as buffer amplifiers.
Thus Today we Learnt about the Common Base Bipolar Junction Transistor Amplifiers, cleared Some Basic Concepts about them, Implement the Amplifiers in Proteus ISIS and read about the characteristics and advantages of the Common Base Bipolar Junction Transistors Amplifiers.
Series Clippers and its types in Proteus
Hello friends, I hope you all are having fun. In today's tutorial, we will have a look at Series Clippers & their types in detail, we will also implement the simulations of Series Clippers in Proteus software. In the next article, we will discuss the next two types of Clippers i.e. Shunt Clippers & Dual Clippers. Today, We are going to learn:
- What is a Clipper?
- What are the types of Clippers?
- Series Clippers Simulations in Proteus.
So, let's get started:
What is a Clipper???
- Clipper (also known as Limiter) is an electronic circuit, which clips or limits the amplitude(positive, negative or both) of an AC source wave.
- Diodes are normally used for designing Clippers and such circuits are normally referred as Diode Clipping Circuits (Diode Limiting Circuits).
- Here's an example of a Diode Clipping Circuit, where we are clipping the positive amplitude of the AC pulse:
- As you can see in the above figure, we are clipping the positive side but if we want to clip the negative side, we just need to reverse the diode polarity.
- Clippers are normally used for protection purposes i.e. if there are some voltage spikes then clip it to secure home appliances.
- Half wave Rectifier is also a type of clipper as it clips one side of the AC pulse to 0V.
Now, let's have a look at different types of clippers:
Types of Clippers
In the previous section, we have had a complete understanding of what is clipper. Now let's have a look at three different types of Clippers:
- Series Clippers.
- Positive.
- Positive with bias.
- Negative.
- Negative with bias.
- Shunt Clippers.
- Positive.
- Positive with bias.
- Negative.
- Negative with bias.
- Dual (Combination) Clippers.
As today's topic is about Series Clippers, so let's implement them in Proteus ISIS:
Series Clippers Simulation in Proteus
- First of all, we need to open the Proteus ISIS software to design our circuit.
- Select the following components from the "Pick Components" section:
- Diode
- Resistor
- Vsine source
- Battery
- So, first of all, let's place our AC source Vsine and GND in the proteus workspace.
- Double-click on the Vsine source and change the value of amplitude and frequency to 11V
and 1000Hz
respectively.
Our power source is ready, now let's design different types of Series Clippers in proteus:
1. Positive Series Clippers in Proteus ISIS
- In Positive Series Clipper, the positive half cycle of the wave is clipped(removed).
- In the positive clipper circuit, the arrowhead of the diode points towards the input source.
- So, let's design the circuit as shown in the below figure:
- As we can see in the above figure, diode D is connected in series with the load
resistor and is pointing towards the AC source.
- Double-click at the resistor and change its value from 10k ohm to 500 ohms.
- We'll also add the DC voltmeter to show the difference between biased and unbiased circuit
- We've connected terminal A of the oscilloscope with the AC Source(Vsine) and terminal B is placed after the diode.
- This is the time to pop the play button and set values of the oscilloscope according to the below table:
Components |
Values |
Channel A |
20V |
Channel B
|
20V
|
Time |
0.2ms-1 |
- If everything goes fine, we will get the required output as shown in the figure:
- In the above figure, the Yellow curve is showing the input voltage, while the blue line is the output voltage(after the diode) received by the load resistor.
- We can clearly see that the positive side of the AC source waveform is now clipped and that's why it's called Positive Series Clipper.
2. Positive with Negative Bias Series Clipper
The Positive Series Clipper removes the positive side of the curve completely but what if we want to clip only 25% of the positive side? In that case, we use positive with Negative Bias Series Clipper. It's circuit is shown in the below figure:
As we can see in the above figure, we have added an extra element called Battery.The rest of the circuit is same as that of the Positive Series Clipper i.e. the diode is
pointing towards the current source and is in series with the resistor.
The volt meter is giving us -5V, where the 5V is coming from the added battery and the negative sign shows that the circuit is negative bias.
- The output for the circuit on the oscilloscope is shown below:
As you can see in the above figure, the output curve is slightly clipped at the top. If we reduce the battery voltage, the clipping of the curve increase and at 0V the complete positive part will be clipped out(same as Positive Series Clipper).
If you want a clipper with a positive bias, simply change the direction of the battery. Connect the negative terminal of the battery with the negative side of the diode. It's a task, post your results in the comments.
3. Negative Series Clipper in Proteus
- In a Negative Series Clipper, the negative half cycle of the wave is clipped(removed).
- In negative clipper circuits, the arrowhead of the diode points towards the load resistor.
- Here's the circuit diagram of the Negative Series Clipper:
- The circuit is the same as that of the Positive Series Clipper with a slight difference in the direction of the diode.
- The output of the oscilloscope for the series circuit of negative clippers shows us that the negative side of the wave is clipped:
4. Negative with negative bias Series Clippers
As we discussed, the whole negative part of the signal gets clipped in the Negative Series Clipper. So, in order to clip a certain amount of negative side, we need to add a new battery source and this model is called Negative with Negative Bias Series Clipper. It's circuit diagram is shown in the below figure:
As we can see in the above figure, the diode is pointing towards the load resistor. We have connected the negative terminal of the battery with the positive side of the diode. Here are the results from the oscilloscope:
So, that was all for today. In this article, we studied the series clipper and its types, along with their simulations in Proteus software. I hope you have enjoyed today's lecture. Let me know your feedback/queries in the comments. Have fun!!!
Simplest Half Wave Rectification in Proteus
Hello friends, I hope you all are doing great. In today's tutorial, I will show you how to perform Simplest Half Wave Rectification in Proteus. In this tutorial, we will design a simple Proteus simulation, where we will use a diode for half-wave rectification.
Before designing the Proteus simulation, we will first have a theoretical overview of Half Wave Rectification as it's always the best approach to read theory before practical (Proteus Simulation). So, let's get started:
What is Rectification ???
- Rectification is an electrical process, used to convert Alternating(AC) Voltage into Direct(DC) Voltage using a circuit called rectifier.
- The Rectification process is always carried out using diodes, as we know diodes allow the current to flow in one direction only, thus they can easily block the opposite flow of alternating current.
- Based on DC output, rectification is divided into two types i.e.
- Half-wave rectification. (needs single diode)
- Full-wave Rectification. (needs multiple diodes)
- Now, let's have a look at, what's the difference between these two types of rectification processes:
Half wave Rectification
- In Half Wave Rectification, half wave of Alternating(AC) Voltage gets converted into Direct(DC) Voltage, while the other half gets blocked.
- A single diode is used for Half Wave Rectification, as shown in the below figure:
- We can allow either pulse(positive or negative) to pass or block and it depends on the diode's direction.
- In the above figure, we are allowing positive AC pulses to pass, while blocking the negative AC pulses.
- If we reverse the direction of the diode, it will block positive pulses & will allow negative ones.
Full Wave Rectification
- In Full Wave Rectification, a complete alternating(AC) pulse(both positive & negative) gets converted into Direct(DC) voltage.
- As you can see in the above figure, we are now utilizing both cycles of AC current and converting them into DC current.
- Hence, the full wave is more efficient than a half wave, as we have seen half wave simply drops half of the pulse.
As today's topic is about Half Wave Rectification, so we won't discuss it in detail but I hope, now you must have understood the difference between full wave & half wave. Let's design half wave rectifier in Proteus:
Half Wave Rectification in Proteus ISIS
- Proteus is one of the best software for simulating electrical/electronic circuits.
- Basically, we have to design a really simple circuit, as shown in the below figure:
- In order to design this half-wave rectifier, we will need these three components:
- Sine Wave Generator.
- Diode.
- Resistor.
- So, click on the “pick” button and select these components from Proteus Library, as shown in the below figure:
- Now, let's design our circuit, so drag & drop these components one by one in the word space.
- Set the resistor's value to 500 ohms.
- Connect a ground terminal as we are using Vsine i.e. the alternating current source. You will find the GND component in the Terminal area from the left menu.
- Now let's connect the wires, as shown n below figure:
- Once we have completed the basic circuit, we’ll now analyze our output on the Oscilloscope.
- You will find it in the left menu under "Virtual Instruments".
- The Oscilloscope has four terminals named A, B, C, D. We’ll connect Terminal A before Diode and Terminal B after the diode, to analyze both Input and output at the same time.
- Double Click on the alternate current source to set the values.
- Here, I am using an amplitude of 110 ms-1 and a frequency of 1000 Hz.
- I have normalized the oscilloscope axes for better examination of the pulses, here are my settings:
- Now run your Proteus simulation, and if everything goes fine, you will get results, as shown in the below figure:
HWR output through Analog Graph:
In the previous section, we have analyzed the curve with Oscilloscope. Now, we are going to use another awesome feature of Proteus i.e.e Analog Graph. We will plot our input/ output curves of Half wave rectifier on the analog graph in Proteus.
- First of all, remove the oscilloscope from the circuit.
- Select the "Current Source" and place one probe before the diode and one after it, to get both input and output at the same time.
- For the output, take the analog option from the graph terminal. Click on the screen where you want the graph. You can make the size of the graph according to your choice.
- So now you have a blank graph screen. You have to set the parameters, add the trace and then simulate it.
- So, let’s do it. Left-click on the graph screen will show you this dialogue box. Choose add trace.
- This will show you the screen where you can add the traces. Once you have added the traces one by one by clicking the required prob, we can proceed.
- This is the time when you have to edit the graph to show right output. Right click again on the graph screen will let you to see the dialogue box again. This time, you have to choose “Edit Graph”. Choose the value according to need. I am choosing "3m"
- .So, you have set all the required thing. This is the time to stimulate your graph and see the required result.
- This is the required result. We give the Input as alternating current, but in the output we got pulsating direct current that flow in one direction.
- We can maximize the result by right click and choosing “Maximize”.
- The green one is the input and the output that is in red is the output i.e. direct current.
So, that was all. This was the tutorial in which we found what is rectification, what is the use of diode in the rectification, how can we use oscilloscope as well as analogue graph to see the result of rectification. For more tutorials and learning stay tuned with us.
How to use IF Else in Python
Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you How to use IF Else in Python. It's our 5th tutorial in python series. In our previous lectures, we have covered the detailed
Introduction to Python and then we have also discussed
Data Types in Python &
How to use Strings in Python. So, now it's time to move on a little further.
In today's tutorial, we will cover If else statement in python and its not that difficult to understand but quite an essential one as its use a lot in programming projects. So, let's get started with How to use IF Else Statement in Python:
How to use IF Else Statement in Python
- IF Else Statement in python takes a Boolean Test Expression as an input, if this Boolean expression returns TRUE then code in IF body will get executed and if it returns FALSE, then code in ELSE body will be executed.
- You can understand it better by looking at its Flow Chart in right figure.
- Here's the syntax of IF Else statement in python:
if number == 10:
print(number)
else:
print('Number is not equal to 10"
- We use if, in our daily life, it is part of our conversation, most of the time.
- For example, I say, If I win a lottery then I will go to a world tour! If I clear the test then I will throw a party.
- Here's another example, that if you are working late hours let say, overtime duty then you will get extra money, else you will not get the extra money.
Let's work with an example:
- Suppose, we have a food chain and our customer has a voucher for it.
- He has a voucher number (which is a code) written on it, by showing it, he can get a discount or he can get a free meal.
- If he is providing a correct secret code, then he will get a free meal offer. Otherwise, he will not be able to avail any offer.
- So, let's design this simple code using If Else statement:
Offer = 500 (This is, by default, price of a meal)
- We will take the input from the user.
voucher_number = input("please enter your voucher number: ")
- Whatever the number he will enter, it will get stored in that "voucher_number".
- Now let's check if the code, that he has entered is correct or not.
- We will need to use the IF statement here and first let's add this condition:
if voucher_number=="9753":
- If the voucher number is matching with the company generated number, then the offer will be:
offer -=300
- If the code is correct then deduct the amount as a discount.
- Then print("congratulations, you have got a discount")
- Then print("your remaining offer has " + str(offer))
- Run the program
- See the image, it says to enter the voucher number in the output window:
Suppose I put the wrong code. It will exit the program. Now what error he will face, if he put the wrong Voucher number, Let’s see what will be the next task.
- We will use else statement for this, if the condition is not correct.
- I have simply printed the message in else body, as shown in below figure:
Relational Operators in Python
As we are discussing IF Else statement, so we should also have a look at relational operators in python:
- Relational Operators are used to find a relation between two variables or data packets.
- We use relational operators in test expressions of IF Else statements.
- We have five types of Relational Operators i.e.
- Greater than >
- Less than <
- Greater than equals to >=
- Less than equals to <=
- Equals to ==
- Let's understand them with an example. Now I have to check which number is greater so I will write it as:
if first_number > second_number:
print(" First number is greater than second number.")
else:
print(“second number is greater than first number.")
So, that was all about How to use IF Else statement in Python. If you have any questions, ask in comments. In the next, lecture, we will have a look at How to design a simple calculator in python. Till then take care & have fun !!! :)
How to use Arithmetic Operators in Python
Hello friends, I hope you all are ding great. In today's tutorial, I am going to show you How to use Arithmetic Operators in Python. It's our fourth tutorial in Python series. Arithmetic operators are required in mathematical problem solving.
We will first have a look at the arithmetic operators and after that, we also discuss different builtin arithmetic functions in Python Math module. So, let's get started:
Arithmetic Operators in Python
- Arithmetic operators ( +, -, *, /, ^ etc. ) are used to perform simple arithmetic operations in python.
- So, let's open up your PyCharm and perform a simple task using these operators, as shown in below figure:
- I used a single star for multiplication and a double star for the square power.
- It is showing the results of the operations, which it is performing respectively.
Now let's design a simple calculator using these arithmetic operators but before that let's have a look at How to take input from user in python.
Getting Input from users in Python
- If we want to work dynamically, we will learn how we get values from users.
- It quite simple in python, you will just need to use an input method here.
- It will take input from the user and store it in the assigned variable.
- If you want to take the full name, age, and qualification of the player, you will write it as shown in the image:
Now I will talk about type conversion and we will make a simple program that will calculate the salary of an employee so that we can learn to perform basic calculations:
Type conversion in Python
In this part, I will tell you, what is Type Conversion in Python? And why it is required? Let's follow the step.
- Suppose we want to count the salary of an employee. See the steps in the image.
- Here I put int. before the fourth string, which is basic pay, but I have put the bonus in the whole numbers and it will be unable to do the concatenation because it is allowing it as a string. So, I typed the data and run it, see the results.
- You can also use the second method as you can put int. where you are performing calculations, as shown in the image.
- You can convert it by using three major data types i.e. int, float, string.
Simple Calculator in Python
Now we will design a simple calculator in which the user will enter 1st & 2nd number and our code will perform these operations with those operators like addition, subtraction, division, and multiplications. I typed the following strings below:
- first_number = float(input("Enter first number : "))
- second_number = float(input("Enter second number : "))
- print("All Arithmetic Operations are as under.")
- print(first_number + second_number)
- print(first_number - second_number)
- print(first_number * second_number)
- print(first_number / second_number)
- print(first_number ** second_number)
- I converted the type of first and second strings.
- Run the program
- You can see in the printed screen all the arithmetic operations are performed respectively.
- All the values are in floating points because we converted it into the float.
- You can also convert it in integer and check it.
- I wrote 9 and 5 and enter it, results are shown in above figure.
Operator Precedence in Python
Let's suppose, we have a variable here.
- Profit = 15 + 30 * 25
- Now let's print it using: print(profit)
- Run the program.
- The answer will be 765 in the output window.
Python follows the standard order of precedence. First, it will perform multiplication and then it will perform the addition. However, we can change the order using parenthesis.
- Suppose, we want to operate the addition method first.
- So, I will place parenthesis before and after both terms.
- Then it will perform the addition method first then multiplication.
- I will write it as:
profit = (15 + 30) * 25
- Run the program and answer will be 1125.
Now I will expand the equation and will do subtraction with it, let’s see what happens.
profit = (15 + 30) * 25 - 10
- Run the program and answer will be 1115.
- If we add parenthesis to it as:
profit = (15 + 30) * (25 - 10)
- Run the program and we will get 675.
Numbers and Importing Math’s Function in Python
In this part of the lecture, I will discuss predefined functions about numbers in Python and I will also show you, how to import math modules for the advanced predefined function and methods, predefined for numbers. So let's get started.
round()
- Suppose we have a variable as, number = 3.7.
- I want easily round it using:
print(round(number))
- Run the program and it will round the figure to 4.
abs()
- Suppose I have negative value -8 and I want to find the absolute value of it.
- I will use abs() and it It will return 8, as shown in below figure:
min()
- If I want to find the minimum value among the two numbers. I will write it as:
print(min(9, 4.5)
- It will return the minimum value as, 4.5.
max()
- You can do the exact opposite of min, if you want to find out the maximum value among the two numbers.
print(max(9, 4.5)
pow()
- If I want to calculate the multiples of itself i.e. square, cube etc. then I will write it as:
print(pow(5, 3)
- The first number will be base and the second one will be the power.
- Run the program & it will show the answer, 125.
Import a Math Module in Python
Now let's have a look at How to import a math module in python code:
- Python Math library has a lot of builtin functions, which we can easily import by writing this statement at the top of our code.
from Math import *
- By writing this statement we are simply saying that get access to all the functions of Math Library.
Now, let's have a look at few of its functions:
sqrt()
- Suppose I want to take the square root of number = 72
- I write it as
print (sqrt(number))
- Run the program and it will return as 8.4 something, as shown in below figure:
Here's the complete list of functions in Python Math Module:
List of Functions in Python Math Module
Function |
Description |
ceil(x) |
It returns the previous integer value. |
copysign(x, y) |
It will assign sign of y to x. |
fabs(x) |
It returns the absolute value. |
factorial(x) |
It returns the factorial value. |
floor(x) |
It returns the next integer value. |
fmod(x, y) |
It divides x by y and returns the remainder. |
frexp(x) |
It returns the mantissa and exponent as pair value. |
fsum(iterable) |
It returns an accurate floating point sum of values in the iterable |
isfinite(x) |
It returns TRUE, if the number is finite i.e. neither infinite nor NaN. |
isinf(x) |
It returns TRUE, if the number is infinite. |
isnan(x) |
It returns TRUE, if the number is NAN. |
ldexp(x, i) |
It returns x * (2**i). |
modf(x) |
It returns the fractional and integer values. |
trunc(x) |
It returns the truncated integer value. |
exp(x) |
It returns e**x |
expm1(x) |
It returns e**x - 1 |
log(x[, base]) |
It returns the logarithmic value to the base e. |
log1p(x) |
It returns the natural logarithmic value of 1+x. |
log2(x) |
It returns the base-2 logarithmic value. |
log10(x) |
It returns the base-10 logarithmic value. |
pow(x, y) |
It returns x raised to the power y. |
sqrt(x) |
It returns the square root of x. |
acos(x) |
It returns the arc cosine of x. |
asin(x) |
Returns the arc sine of x. |
atan(x) |
Returns the arc tangent of x. |
atan2(y, x) |
Returns atan(y / x) |
cos(x) |
Returns the cosine of x |
hypot(x, y) |
Returns the Euclidean norm, sqrt(x*x + y*y) |
sin(x) |
Returns the sine of x |
tan(x) |
Returns the tangent of x |
degrees(x) |
Converts angle x from radians to degrees |
radians(x) |
Converts angle x from degrees to radians |
acosh(x) |
Returns the inverse hyperbolic cosine of x |
asinh(x) |
Returns the inverse hyperbolic sine of x |
atanh(x) |
Returns the inverse hyperbolic tangent of x |
cosh(x) |
Returns the hyperbolic cosine of x |
sinh(x) |
Returns the hyperbolic cosine of x |
tanh(x) |
Returns the hyperbolic tangent of x |
erf(x) |
Returns the error function at x |
erfc(x) |
Returns the complementary error function at x |
gamma(x) |
Returns the Gamma function at x |
lgamma(x) |
Returns the natural logarithm of the absolute value of the Gamma function at x |
pi |
Mathematical constant, the ratio of circumference of a circle to it's diameter (3.14159...) |
e |
mathematical constant e (2.71828...) |
So that was all about arithmetic operators in Python. I hope now you got the clear idea of how powerful python is. So, that was all for today. In the next lecture, we will have a look at How to create IF Loop in Python. Till then take care and have fun !!! :)
How to use String in Python
Hello friends, I hope you all are doing great. In today's tutorial, we will have a look at How to use String in Python. It's our 3rd tutorial in Python series. We have discussed strings in our previous lecture
How to use Data Types in Python.
String is a most commonly used data type in python that's why I have created a separate lecture on it. Python has many built-in string operations, which we will discuss today in detail. So, let's get started with String in Python:
How to use String in Python
- String Data Type is used to store or collect one or more characters or sequence of characters, we can place any alphanumerical or special character in a string.
- Let's create a string in python, it has a simple syntax, as shown below:
first_var = "Hello World"
- There are two sorts of strings, we can use in python:
- Single Line.
- Multiple Lines.
- The above-given example is for a single line, like if you want to write an email or product name, etc.
Multiple Lines String in Python
- If you want to write an essay, story, report etc. then you will need to use Multiple Lines string, which is created by placing triple quote around the data, as shown in below figure:
- As you can see in above figure, we have written multiple lines in welcome string.
Strings Operators
- If you are using an apostrophe, you will need to use use double quotes, otherwise, the interpreter will not be able to understand it and will give you a syntax error, as shown in below figure:
- But if I write in double-quotes, then it will work fine, as shown in below figure:
Escape sequences in Python
- If you are using double quotes in the same string, then you will need to use a backward slash ( \ ), as shown in the image.
- Run the program and see the result in the console window:
Now I have another escape sequence ( \n )
- If I want to add a new line break then I will use escape sequence ( \n ).
- As you can see in below figure, I have printed the name & age of Richard in separate lines using escape sequence ( \n ).
Tab escape sequence is \t
- I wrote it with tab escape sequence ( \t ) and run the program, see the six spaces in the printed window:
Some useful points before I move further:
- You can use backward slash and forward slash \/ like this.
- You cannot use the backward slash at the end of the string before the end of the quote.
- You will use double backward slash ( \\ ), if you want to print one.
Concatenation in Python
- In concatenation, we connect multiple strings together, we use ( + ) sign in order to concatenate strings.
- Let's understand it with an example, as shown in below figure:
- As you can see in above figure, I have printed multiple strings in a single line using ( + ) sign.
String Formatting In Python
When we use multiple strings, it gets harder to concatenate those strings, and it is difficult to remember each string format and codes. In such cases, we need to format those strings. Let's understand it with an example:
- In String Formatting, we simply place our variables in curly brackets, as shown in below figure:
- No need to add multiple quotes and + symbol, instead simply use curly brackets for variables.
String Indexes in Python
In python, when we store a string, it goes with an index for each of its element one by one, because it is a sequence of characters. Let's understand it with an example:
- For example, I saved the name "Ali Haider" in a string then each of its character has an index assigned with it.
- I have shown the string and the index starting with a comment # in below image:
- So, that means index of A=0, L=1, I=2, (for blank space, it is also a character and its index is 3), H=4, a=5, i=6, d=7, e=8 and r=9.
- After that, I have printed first three characters of that string by writing a range of [0:3], it eliminates the ending index and shows the result as from 0 to 2, which makes the word Ali. (see above image )
- If you want to print till the final value, then you wont need to write the last index, you will just write it as [0: ].
- If I write in this way, print(player_name[:]), then it will print the whole string again.
- You can also write negative indexes like print(player_name[-1]) and it will print r from the right side.
Before moving further, I will tell you a magical feature that only Python allows.
- Type print("a" * 30) and check the magic in print window:
Builtin String Functions in Python
Python has numerous excellent builtin string functions, which we can access using
DOT ( . ) operator. These builtin functions are quite helpful, so let's have a loot at few of them:
string.upper()
- This upper() function will make characters of the string uppercase, as shown in below figure:
- If, I write print(Precaution.isupper()), It will check the string, whether its uppercase or not.
- If string will be in uppercase it will return True and if it's not in uppercase, it will return False.
string.lower()
- Now let's convert string characters to lowercase by using lower() function.
- When I type print(precaution.lower()), It will print the whole string in lowercase, as shown in below figure:
string.replace()
- Now if we want to replace any word, then we need to use print(precaution.replace("WEAR", 'BUY')), It will replace the WEAR word with BUY, as shown in the image:
So, that was all about How to use Strings in Python. I have tried to cover all the main points and rest we will keep on covering in coming lectures. In the next lecture, we will have a look at How to use Arithmetic Operators in Python. Till then take care & have fun !!! :)
How to use Data Types in Python
Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you
How to use Data types in Python. It's our 2nd tutorial in Python series. In our first tutorial, we have seen a detailed introduction to python and we have also installed PyCharm IDE to work on python.
Today, we will understand data types in detail as in order to design an efficient program, you need to select correct data types. Incorrect selection may cause memory loss and may slow your application. So, let's get started with data types in Python:
Data types in Python
- Data Types are used for the classification or categorization of similar data packets. There are numerous data types available in python, which we can use depending on our projects' requirement.
- Let's understand data types with an example: Suppose you have some digital data i.e. ON & OFF then you can save this data in Boolean data type but what if your data ranges from 1 to 10, then you need to use integer data types instead of Boolean.
- You can save Boolean data in integer data type but that will be a redundant i.e. we are allocating more space to our data by specifying integer, when we can easily assign Boolean to it.
- Here's the flow chart of available data types in Python language:
Now let's have a look at these data types one by one:
Numeric in Python
- Numeric data types are used to deal with all types of numerical data packets i.e. integer, float etc.
- Numeric data types are further divided into 3 types, which are:
- Integer.
- Float.
- Complex Number.
Integer in Python
- Integer (int) data type only holds integer numbers, it could be positive or negative.
- We can't save decimal numbers in integer data type.
- Here's a declaration of a variable x and it is assigned a value a of integer 20:
x = int(20)
Float in Python
- Float data types are used to hold decimal numerical values i.e. 2.13, 3.14 etc.
- We can also save whole numbers in float data types.
- Here's a declaration of a variable x and it is assigned a value a of float 20.5:
x = float(20.5)
Complex Numbers in Python
- Complex Number data types is used to keep complex numbers in it. Complex numbers are those numerical values which have real & imaginary part.
- That's the versatility of python language, I haven't seen complex number data type in any other programming language.
- Here's a declaration of a variable x and it is assigned a complex number 1+3j:
x = complex(1+3j)
Dictionary in Python
- Dictionary data type is sued to save data in key -> value form. The data is unordered but the value is paired with its key.
- Dictionary data is placed inside curly brackets i.e. {1:"Jones", 2:"IronMan", 3:"Football", 4: "Mosque"}.
- Here's a declaration of a variable x and it's assigned a dictionary data type:
x = dict(name="John", age=36)
Boolean in Python
- Boolean is the simplest data type of all and has just two values assigned to it i.e. True or False.
- Although it's quite simple but its too handy as we have to use it a lot in IF statements. ( We will cover that later )
- Here's a declaration of a variable x, assigned a Boolean data type and it's TRUE:
x = bool(1)
Sequence Type in Python
- Sequence Type data types are used to save data in characters form.
- We can't save numerical data in sequence type but we can convert the two. ( We will discuss that later )
- Sequence Types are further divided into 3 types, which are:
Strings in Python
- A string is used to save one or more characters and it's the most commonly used data type.
- Let's understand it with a simple example: You must have seen greeting messages on different projects, we save such data in strings.
- We will discuss strings in detail in our next lecture, where we will perform different operations using strings.
- Here's a declaration of a variable x, which is assigned a string "Hello World":
x = str("Hello World")
List in Python
- List data type is used to collect an ordered data, not necessarily of the same type.
- List data is displayed with square brackets.
- We will discuss this in our upcoming lectures in detail, here's a declaration of list:
x = list(("apple", "banana", "cherry"))
Tuple in Python
- Tuple data type is used to arrange ordered data, it's quite similar to list but the data is displayed with small brackets.
- Here's a Tuple declaration:
x = tuple(("apple", "banana", "cherry"))
So, we have discussed all these data types in python and if you are not understanding any of them yet then no need to worry as we are going to use them a lot in our coming projects, so you will get them. Before moving to next lecture, let's discuss variables in python a little:
Variables in Python
- Variable is a temporary location in computer's memory, which is used to save the data.
- As the name implies, we can change its value using different operations or information given to the program.
- Typically, a program consists of commands that instruct the computer what to do with variables.
- Variables are assigned with tag name, using which we call the value saved in it.
- For examples: x = 5, here x is the name of the variable and 5 is its value.
- In python, we can use special characters, letters, and any number as a variable name.
- Wide spaces and signs with meanings like "+" and "-" are invalid in python.
- You should remember that the names of variables are case sensitive. As the uppercase letter "A" and lowercase letter "a" are considered as different variables.
- As variables are used to save data thus they also assigned a data type. So, a variable could be of int, float or string. (as we seen above)
- In python, it's not necessary to define variable data type, python sets it dynamically.
- There are some variables, which are reserved and we cannot use them.
- We can also change the variables later and assign it to a new variable.
- For example, I have set a value 10 in a variable eat.
eat=100
- Then I added and stored the value of eat+10 in a variable cot.
cot = eat + 10
Types of Variables
Here I have set some examples of Variables and their types.
- X = 456 #integer
- X = 456L #Long integer
- X = 4.56 #double float
- X = "world" #string
- X = [1, 2] #list
- X = (0, 1, 2) #tuple
- X = open('world.py' , 'r') #file
You may assign a single value to multiple variables at the same time.
- Variable x, y, and z are assigned with the same memory location with the value of 1.
x = y = z = 1
- Let's create few variables in python, I have created first_name, date_of_birth & last_name, as shown in below figure:
- I have printed first_name and its appeared in the output panel.
So, that was all about Python Data Types & variables. I hope you have enjoyed today's lecture. In our next lecture, we will have a look at Strings in Python. Till then take care & have fun !!! :)
Introduction to Python
Hello Engineers! Hope you all are doing great. In today's tutorial, I am giving you a detailed lecture on Python programming language. As I am writing this tutorial for beginners, that's why I will discuss each & everything in detail, so it's going to be a very lengthy tutorial and I have divided it in parts.
We will start from basic concepts in Python and will slowly move towards advanced concepts. It's going to be a quite long bumpy ride but I will try my best to make it as smooth as I can. So, let's get started with basic Introduction to Python Language:
Introduction to python
- Python is a multi-purpose, object-oriented High-Level Programming language, with applications in multiple areas, including scripting, machine learning, data sciences, scientific learning, cloud computing and artificial intelligence.
- It is the most popular language of 2019, and it is going to flourish exponentially in upcoming years because of its versatility & flexibility.
- Organizations like Google, NASA, and CIA are using it already.
- Python processes at RUNTIME by the INTERPRETER, so you don't need to compile your program before executing it.
- There are three major versions of Python programming language are available i.e. 1.X, 2.X and 3.X. They have sub-versions such as 2.2.3 and 3.3.1.
So, the IDE (Integrated Development Environment) which I am going to use is PyCharm Community Edition.
- PyCharm Community Edition is free of cost and open-source. You can use it easily.
- Jetbrains developed this for professional developers.
Prerequisites for Python
As I have told you earlier, I will start from the very basics and will cover almost everything about Python, so if you follow & practice this tutorial completely then you will surely learn Python, even if you are a beginner and know nothing about programming. But still, it would be better if you have:
- knowledge of some basic concepts like loops, control statements, variables, etc.
- It is not required to learn any other programming language before you learn python.
- It is not required to have an engineering background to learn this language.
- If you are from any other discipline like Sciences, Social sciences or any other academic field, you can still learn it.
Uses of Python
- As I have mentioned earlier, Python is used in various areas like Machine learning, scripting, scientific computing, Artificial Intelligence, cloud computing etc.
- So many communities are forced to use python these days, such as:
- Network Engineers.
- Software Engineers.
- Data Analysts.
- Mathematicians.
- Scientists.
- Accountants.
- Website & App Developers.
- A wide range of jobs are using this multi-purpose language, namely:
- Desktop application development.
- Mobile application development.
- Web application development.
- Automation Scripts.
- Algorithmic and high-frequency trading.
- Machine learning.
- Artificial intelligence.
- Software testing.
- Hacking.
- Mathematics.
- Networks.
I hope now you have the idea of Python's importance these days. So, let's move on to the next step.
DATA SCIENCE AND MACHINE LEARNING
Data science and machine learning are the main reasons, why programmers are learning this language.
- Python offers different frameworks and libraries, for example, PyBrain, PyMySQL, and NumPy.
- Python experience allows you more than R Language.
- You can create scripts to automate material and go with web developments, and so on, respectively.
- If you want to work in machine learning, you can easily work with Python.
- Some of the examples of machine learning are, google chatbots. They answer your questions and queries through python algorithms.
Download & Install Python
Enough with the theoretical stuff, now let's get our hands on Python software:
- First of all, you need to download Python, they have provided Python for Windows, Linux/UNIX, Mac OS X etc.
- At the time of this writing, Python 3.8.3 is the latest version, so download & install it.
- Make sure you check the Python path when you continue, otherwise, it will not work in the future.
- Next, we need to download PyCharm, which is the IDE for professional developers.
- You will find two versions on its download page i.e. Professional and Community.
- We are going to download the community version for now, as we are in the learning phase.
- You can download PyCharm for Windows, Mac & Linux.
- After downloading the PyCharm, simply install it.
- During installation, you need to check on the
- 64-bit launcher.
- Add launcher dir to the PATH.
- Create Associations .py
- I have ticked these 3 options, as shown in the below image:
- Now click on the Next button and then click on Install and PyCharm will be installed on your computer.
- You need to restart your computer for adding launcher dir to the PATH.
Creating First Python Project on PyCharm
- Click the PyCharm icon and open the IDE.
- On its first run, it will ask for the UI theme, which I am going to select Dracula, as I like the dark one.
- Now, click on "Create New Project, select the location where you want to save your file and then click close.
We have created our first project in PyCharm and next, we need to add python files to this project. So let's start with the first Python program.
- In the left window titled Project, we have a tree structure of our files.
- These are library files that are necessary for running the project successfully, we will discuss them later.
- So, in this Project Panel, we need to right-click on our Project Folder and then New and then select Python File, as shown in the figure on the right side.
- Give a name to your file, as I have named it myy.py.
- Now let's write our first line of code:
print("my world, my rules")
- Click on Run in the top menu bar then select Run. You can also use the shortcut key (Alt+shift+F10).
- IDE will ask you to select the file for execution, so we need to select our python file.
- Once you select your python file, a new dialog box will open up at the bottom, and you will find your string printed there i.e. my world, my rules.
- Here's the screenshot of our first Python code in Pycharm:
- So, we have successfully executed our first Python code in PyCharm. :)
So, that was all for today. I hope now you have a better understanding of what python is and why its so popular. If you have any questions, please feel free to as kin comments. In the next lecture, we will have a look at datatypes in python. Till then take care and have fun !!! :)