0% found this document useful (0 votes)
4 views8 pages

Python Programming

The document provides instructions on how to open PyCharm software, create a new project and python file, and run a python program in PyCharm. Key steps include clicking the search box and double clicking the PyCharm icon to open it, selecting "File > New Project" and providing a name and location, right clicking the project name and selecting "New > Python File", and right clicking the python file and selecting "Run" to execute the code. Examples of python code include name and age, full name, simple interest calculator, area of rectangle calculator, and a mini calculator.

Uploaded by

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

Python Programming

The document provides instructions on how to open PyCharm software, create a new project and python file, and run a python program in PyCharm. Key steps include clicking the search box and double clicking the PyCharm icon to open it, selecting "File > New Project" and providing a name and location, right clicking the project name and selecting "New > Python File", and right clicking the python file and selecting "Run" to execute the code. Examples of python code include name and age, full name, simple interest calculator, area of rectangle calculator, and a mini calculator.

Uploaded by

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

Python Programming

Q. How to open PyCharm software?

Ans.

Click on the “search box”.

Type PyCharm.

Double click on the icon.

Q. How to create new project?

Ans.

Open “PyCharm” software.

Close the “current file” and close the “Tip of the day window”

Click on the “File” menu

Go to “New Project” and click on that.


Provide proper name in the location box, but don’t delete the project path.

Project Name is marked with the orange line and project path is marked with blue line. You only
need to change the part that is marked with orange line. Don’t change anything else.

Then click on the create button.

Click on “This Window” button.


Q. How to create new python file?

Ans

After creating the new project the following window will appear.

Close the [Link] by click on the cross button.

Right click on your project name.

Go to New

Then click on the Python File.

The following window will appear and provide proper name in the Name box.

Then press Enter button from the Keyboard.


After that the following window will appear. Here project name and the file names are marked.

Type your code in the blank area.

Q. How to run your programme?

Ans.

Right click on the Python File you want to run.

Click on the Run button form the drop down.


Else

Press Ctrl + Shift + F10 button together from the keyboard.

Else

Click on the dropdown arrow beside main from the run box.

Run Button.

Dropdown Arrow.

Click on the Current File.

Then click on Run button.

Python codes:

1. Write a python program to show you name and age.


Ans.
name=str(input("Enter your name: "))
grade=str(input("Enter your grade: "))
section=str(input("Enter your section: "))
age=float(input("Enter your age: "))
roll=int(input("Enter your roll number: "))
print("My name is: ",name)
print("My grade is: ",grade)
print("My section is: ",section)
print("My age is: ",age)
print("My roll number is: ",roll)
Output:

……………………………………………………………..
2. Write a python program to enter your first name and last name and show you name.
Ans.
fnm=str(input("Enter Your First Name: "))
lnm=str(input("Enter Your Last name: "))
fullname= fnm+lnm
print("My Full Name is: ",fullname)

Output:

…………………………………………………………………..
3. Write a python program to create simple interest calculator.
Ans.
p=float(input("Enter the Principal: "))
r=float(input("Enter the Rate: "))
t=float(input("Enter the Time in Years: "))
si=p*r*t/100
a=p+si
print("Simple Interest is: ",si)
print("Amount is: ",a)

Output:

……………………………………………………………
4. Write a python program to calculate a python program.
Ans.
length=float(input("Enter the Length of the Rectangle: "))
breadth=float(input("Enter the Breadth of the Rectangle: "))
area=length * breadth
print("The Area of the Rectangle is: ", area)
Output:

………………………………………………………………..
5. Write a python program to create mini calculator.
Ans.
a=int(input("Enter the first number: "))
b=int(input("Enter the second number: "))
sum=a+b
sub=a-b
product=a*b
div=a/b
remainder=a%b
print("Sum of the numbers is: ",sum)
print("Difference between the numbers is: ",sub)
print("Product of the numbers is: ",product)
print("The Quotient is: ",div)
print("The Remainder is: ",remainder)

Output

Common questions

Powered by AI

Using PyCharm's project creation features provides a structured environment where initial configurations, such as interpreter choice, library dependencies, and folder structures, are well-managed, aiding in reducing configuration errors and improving productivity. However, manually managing Python scripts allows greater flexibility and control over environments, especially important in distributed systems or when using virtual environments bespoke for specific projects. PyCharm's integrated features, such as a debugger, code suggestion, and refactoring tools, offer robustness and efficiency over manual management, which can increase the risks of human error and inefficiency.

To create a new Python project in PyCharm, first open the PyCharm software, then close the current file and the 'Tip of the Day' window. Next, click on the 'File' menu, go to 'New Project', and click on it. Provide a proper name in the location box without deleting the project path, then click the 'Create' button. Finally, click on the 'This Window' button.

Optimizing Python program execution in PyCharm can include configuring the IDE settings to pre-set the environment variables and integrate configurations for automated testing through continuous integration plugins. Regularly using keyboard shortcuts, such as Ctrl + Shift + F10, can minimize time spent navigating through menus. Additionally, configuring run profiles to automate parameter input and switching to faster Python interpreters, such as PyPy if supported, can enhance execution speed.

In PyCharm, you can automate the running of a Python script by right-clicking on the Python file you wish to run, then selecting the 'Run' button from the dropdown menu. Alternatively, you can press Ctrl + Shift + F10 on the keyboard. Additionally, you can click on the dropdown arrow beside 'main' from the run box, select 'Current File', and then click the 'Run' button. These steps help integrate the process within the IDE settings, allowing for streamline execution and automation of tasks.

Setting up a basic project in PyCharm involves opening the IDE, creating a new project via the 'File' menu, and inputting a suitable name while ensuring the correct path is set. This contrasts with running scripts directly from a command line, where one typically just navigates to the directory containing the script and runs it using `python script_name.py`. PyCharm provides additional setup steps such as configuring environment variables, dependencies, and project settings, which simplify build management and testing, whereas the command line offers simplicity and directness with fewer preliminary configurations.

When creating a new project in PyCharm, it's crucial not to modify the project path as it is marked with a blue line to ensure the project's configurations and dependencies are correctly located and managed within the IDE. Modifying the path might lead to issues with locating the files and executing the project, as the built-in configuration assumes files are in specific directories for optimal operation.

When concatenating strings in Python, using the '+' operator is the simplest method, as shown in the code example combining first and last names: `fnm=str(input("Enter Your First Name: ")) lnm=str(input("Enter Your Last name: ")) fullname= fnm + lnm print("My Full Name is: ",fullname)`. However, attention must be paid to managing spaces between concatenated strings, as '+' does not add any delimiters by default. Using f-strings or 'join()' method for more complex cases can enhance readability and maintainability.

Using PyCharm is more beneficial than a simple text editor when dealing with larger projects or when requiring advanced features such as integrated debugging, version control, and code navigation. These features allow for easier management of complex codebases, quicker identification and fixing of bugs, as well as better collaboration through version control systems integrations. Furthermore, PyCharm supports refactoring, which improves code maintainability and readability—a feature lacking in simple text editors.

To calculate simple interest in a Python program, use the formula: simple interest = principal * rate * time / 100. Start by taking inputs for the principal, rate, and time variables, then compute the simple interest using the formula mentioned and add it to the principal to get the total amount. Example code: ```p=float(input("Enter the Principal: ")) r=float(input("Enter the Rate: ")) t=float(input("Enter the Time in Years: ")) si=p*r*t/100 a=p+si print("Simple Interest is: ",si) print("Amount is: ",a)```

To create a Python file within a PyCharm project, ensure you are in the correct project after creation. Close the 'main.py' file by clicking on the cross button, then right-click on your project name in the project pane, go to 'New', and click on 'Python File'. In the window that appears, provide a proper name in the 'Name' box and press 'Enter'.

You might also like