100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Notas de lectura

Python notes 150

Puntuación
-
Vendido
-
Páginas
96
Subido en
04-12-2024
Escrito en
2023/2024

**Python 150 Programming Notes by Piush Kumar Sharma** is a comprehensive guide designed for both beginners and experienced programmers. It offers 150 carefully selected programming problems, complete with detailed solutions and explanations. Each problem is structured to enhance your understanding of core Python concepts, including data structures, algorithms, file handling, object-oriented programming, and more. The book is divided into sections that cater to various difficulty levels, making it an excellent resource for those preparing for coding interviews, competitive programming, or simply looking to improve their Python skills. Additionally, the practice exercises help reinforce concepts and encourage hands-on learning. Key features include: - **150 Diverse Programming Problems**: Covers a wide range of topics to ensure well-rounded learning. - **Step-by-Step Solutions**: Clear and concise solutions to help you grasp problem-solving techniques. - **Practice Exercises**: Additional problems to test your knowledge and application skills. - **Beginner to Advanced Topics**: Suitable for all skill levels, from those new to Python to seasoned coders. This book serves as an indispensable resource for anyone aiming to master Python programming effectively and efficiently.

Mostrar más Leer menos
Institución
Grado











Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Libro relacionado

Escuela, estudio y materia

Grado

Información del documento

Subido en
4 de diciembre de 2024
Número de páginas
96
Escrito en
2023/2024
Tipo
Notas de lectura
Profesor(es)
Piush kumar sharma
Contiene
Todas las clases

Temas

Vista previa del contenido

140+
Basic
Python
Programs
This resource can assist you in
preparing for your interview




Piush Kumar Sharma

,11/26/23, 4:53 AM Basic Python Program - Jupyter Notebook




Program 1

Write a Python program to print "Hello Python".

In [1]: 1 print("Hello Python")

Hello Python



Program 2

Write a Python program to do arithmetical operations addition and division.

In [2]: 1 # Addition
2 num1 = float(input("Enter the first number for addition: "))
3 num2 = float(input("Enter the second number for addition: "))
4 sum_result = num1 + num2
5 print(f"sum: {num1} + {num2} = {sum_result}")

Enter the first number for addition: 5
Enter the second number for addition: 6
sum: 5.0 + 6.0 = 11.0


In [3]: 1 # Division
2 num3 = float(input("Enter the dividend for division: "))
3 num4 = float(input("Enter the divisor for division: "))
4 if num4 == 0:
5 print("Error: Division by zero is not allowed.")
6 else:
7 div_result = num3 / num4
8 print(f"Division: {num3} / {num4} = {div_result}")

Enter the dividend for division: 25
Enter the divisor for division: 5
Division: 25..0 = 5.0



Program 3

Write a Python program to find the area of a triangle.

In [4]: 1 # Input the base and height from the user
2 base = float(input("Enter the length of the base of the triangle: "))
3 height = float(input("Enter the height of the triangle: "))
4 # Calculate the area of the triangle
5 area = 0.5 * base * height
6 # Display the result
7 print(f"The area of the triangle is: {area}")

Enter the length of the base of the triangle: 10
Enter the height of the triangle: 15
The area of the triangle is: 75.0


localhost:8888/notebooks/Piush Kumar Sharma/Basic Python Program.ipynb 1/95

,11/26/23, 4:53 AM Basic Python Program - Jupyter Notebook



Program 4

Write a Python program to swap two variables.

In [5]: 1 # Input two variables
2 a = input("Enter the value of the first variable (a): ")
3 b = input("Enter the value of the second variable (b): ")
4 # Display the original values
5 print(f"Original values: a = {a}, b = {b}")
6 # Swap the values using a temporary variable
7 temp = a
8 a = b
9 b = temp
10 # Display the swapped values
11 print(f"Swapped values: a = {a}, b = {b}")

Enter the value of the first variable (a): 5
Enter the value of the second variable (b): 9
Original values: a = 5, b = 9
Swapped values: a = 9, b = 5



Program 5

Write a Python program to generate a random number.

In [6]: 1 import random
2 print(f"Random number: {random.randint(1, 100)}")

Random number: 89



Program 6

Write a Python program to convert kilometers to miles.

In [7]: 1 kilometers = float(input("Enter distance in kilometers: "))
2 ​
3 # Conversion factor: 1 kilometer = 0.621371 miles
4 conversion_factor = 0.621371
5 ​
6 miles = kilometers * conversion_factor
7 ​
8 print(f"{kilometers} kilometers is equal to {miles} miles")

Enter distance in kilometers: 100
100.0 kilometers is equal to 62.137100000000004 miles



Program 7

Write a Python program to convert Celsius to Fahrenheit.



localhost:8888/notebooks/Piush Kumar Sharma/Basic Python Program.ipynb 2/95

, 11/26/23, 4:53 AM Basic Python Program - Jupyter Notebook


In [8]: 1 celsius = float(input("Enter temperature in Celsius: "))
2 ​
3 # Conversion formula: Fahrenheit = (Celsius * 9/5) + 32
4 fahrenheit = (celsius * 9/5) + 32
5 ​
6 print(f"{celsius} degrees Celsius is equal to {fahrenheit} degrees Fahr

Enter temperature in Celsius: 37
37.0 degrees Celsius is equal to 98.6 degrees Fahrenheit



Program 8

Write a Python program to display calendar.

In [9]: 1 import calendar
2 ​
3 year = int(input("Enter year: "))
4 month = int(input("Enter month: "))
5 ​
6 cal = calendar.month(year, month)
7 print(cal)

Enter year: 2023
Enter month: 11
November 2023
Mo Tu We Th Fr Sa Su
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30




Program 9

Write a Python program to solve quadratic equation.


The standard form of a quadratic equation is:

𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0
where

a, b and c are real numbers and

𝑎≠0
The solutions of this quadratic equation is given by:

(−𝑏 ± (𝑏2 − 4𝑎𝑐)1/2)/(2𝑎)


localhost:8888/notebooks/Piush Kumar Sharma/Basic Python Program.ipynb 3/95
$7.89
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
mailtoganeshbehera

Conoce al vendedor

Seller avatar
mailtoganeshbehera Fakir Mohan University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
1 año
Número de seguidores
0
Documentos
6
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes