Codes
Codes
pyplot as plt
import numpy as np
# Following code is new for you. Now we will create a figure which can have several s
# Create a figure and axis object. The name of axis object is ax in our code.
fig, ax = plt.subplots()
# Plot the quadratic equation. The graph line will have green color, thickness as 2 a
ax.plot(x, y, color='green', linewidth=2, marker='o')
# Show gridlines
ax.grid(True)
# Here we are going to create tick marks on x and y axis. Remember, usually one out o
# Therefore, you should try the code twice, once by plotting tick marks only and once
# Set the x-axis tick marks and y-axis tick marks based on the maximum and minimum va
ax.set_xticks(np.linspace(np.min(x), np.max(x), num=11))
ax.set_yticks(np.linspace(np.min(y), np.max(y), num=11))
In [ ]: import turtle
In [ ]: import pygame
# Initialize Pygame
pygame.init()
# Quit Pygame
pygame.quit()
disc=b**2-4*a*c
if disc>0:
print("Real Roots")
x1=(-b+(disc)**.5)/(2*a)
x2=(-b-(disc)**.5)/(2*a)
print("Root 1 = ",x1)
print("Root 2 = ",x2)
elif disc==0:
print("Equal Roots")
x1=-b/(2*a)
x2=-b/(2*a)
print("Root 1 = ",x1)
print("Root 2 = ",x2)
else:
print("Complex Roots")
real=-b/(2*a)
imag=((-disc)**0.5)/(2*a)
x1=str(real)+"+"+str(imag)+" i"
x2=str(real)+"-"+str(imag)+" i"
print("Root 1 = ",x1)
print("Root 2 = ",x2)
In [ ]: import turtle
turtle.speed(1)
turtle.penup()
turtle.goto(-50,50)
turtle.pendown()
red = 255
green = 120
blue = 150
turtle.done()
L = float(input('Length = '))
W = float(input('Width = '))
x = [0, 0, L, L, 0]
y = [0, W, W, 0, 0]
plt.plot(x,y)
plt.title('Section C ka Rectangle')
plt.xlim(0,max(L,W))
plt.ylim(0,max(L,W))
Area = L * W
print('Area = ',Area)
In [ ]: for _ in range(5):
print ('My name is Dr. Ali')
In [ ]: for i in range(2,17,3):
print ('Current Value is',i)
In [ ]: num = [1,5,95,13]
for i in num:
print ('Current Value is',i)
In [ ]: fruits = ['Apple','Banana','Orange','Mango']
for var in fruits:
print ('Current Value is',var)
In [ ]: number = [1,5,95,12,17]
fruit = ['Apple','Banana','Orange','Mango']
print(number*3)
In [ ]: print('Hello World')
In [ ]: name = 'Haider'
age = '18'
print('My name is {} and I am {} years old'.format(name,age))
In [ ]: def cirarea(rad):
return 3.14159*rad**2
# Main Code
A = input('Your Name Plz? ')
greet(A)
# Main Code
a = float(input('Radius = '))
b = CA(a)
print('Area of Circle = ',b)
print('Area of Circle = ',CA(a))