• Complain

King - Python Coding and C Programming Examples: Programming for Stupid

Here you can read online King - Python Coding and C Programming Examples: Programming for Stupid full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2020, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    Python Coding and C Programming Examples: Programming for Stupid
  • Author:
  • Genre:
  • Year:
    2020
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Python Coding and C Programming Examples: Programming for Stupid: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Python Coding and C Programming Examples: Programming for Stupid" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

King: author's other books


Who wrote Python Coding and C Programming Examples: Programming for Stupid? Find out the surname, the name of the author of the book and a list of all author's works by series.

Python Coding and C Programming Examples: Programming for Stupid — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Python Coding and C Programming Examples: Programming for Stupid" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
PYTHON CODING
AND
C PROGRAMMING
EXAMPLES
PROGRAMMING FOR BEGINNERS
J KING
ASCII value of character in Python
In python, we use the function ord() to obtain an ASCII code of a character. Ord() accepts a character, returns its ASCII value.
Syntax:
ord(character);
Example:
Input:
char_var = 'A'
Function call:
ord(char_var)
Output:
Code to find ASCII value of a character
# python program to print ASCII
# value of a given character
# Assigning character to a variable
char_var = 'A'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))
char_var = 'x'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))
char_var = '9'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))
Output
ASCII value of A is = 65
ASCII value of x is = 120
ASCII value of 9 is = 57
Calculate simple interest
We use the following formula to calculate simple interest,
(P * R * T) / 100
Where,
  • P Principle amount
  • R Rate of the interest, and
  • T Time in the years
Example:
Input:
p = 250000
r = 36
t = 1
# formula
si = (p*r*t)/100
print(si)
Output:
90000
Python program for simple interest
# Python program to find simple interest
p = float(input("Enter the principle amount : "))
r = float(input("Enter the rate of interest : "))
t = float(input("Enter the time in the years: "))
# calculating simple interest
si = (p*r*t)/100
# printing the values
print("Principle amount: ", p)
print("Interest rate : ", r)
print("Time in years : ", t)
print("Simple Interest : ", si)
Output
First run:
Enter the principle amount : 10000
Enter the rate of interest : 3.5
Enter the time in the years: 1
Principle amount: 10000.0
Interest rate : 3.5
Time in years : 1.0
Simple Interest : 350.0
Second run:
Enter the principle amount : 250000
Enter the rate of interest : 36
Enter the time in the years: 1
Principle amount: 250000.0
Interest rate : 36.0
Time in years : 1.0
Simple Interest : 90000.0
Calculate compound interest
We use the equation below to calculate compound interest
P(1 + R / 100) T
Where,
P Principle amount
R Rate of the interest, and
T Time in the years
Example:
Input:
p = 250000
r = 36
t = 1
# formula
ci = p * (pow((1 + r / 100), t))
print(ci)
Output:
339999.99999999994
Python program
# Python program to find compound interest
p = float(input("Enter the principle amount : "))
r = float(input("Enter the rate of interest : "))
t = float(input("Enter the time in the years: "))
# calculating compound interest
ci = p * (pow((1 + r / 100), t))
# printing the values
print("Principle amount : ", p)
print("Interest rate : ", r)
print("Time in years : ", t)
print("compound Interest : ", ci)
Output
First run:
Enter the principle amount : 10000
Enter the rate of interest : 3.5
Enter the time in the years: 1
Principle amount : 10000.0
Interest rate : 3.5
Time in years : 1.0
compound Interest : 10350.0
Second run:
Enter the principle amount : 250000
Enter the rate of interest : 36
Enter the time in the years: 1
Principle amount : 250000.0
Interest rate : 36.0
Time in years : 1.0
compound Interest : 339999.99999999994
Python program to check the given year is a leap year or not
A leap year is a year that can be divided by 4, except for the century year (a year that ends with 00). A year of a century is a leap year if it is divisible by 400. Here, the user presents a year, and we will test if the year in question is a leap year or not. We can solve this problem in two ways first by using the calendar module, and second by simply checking the state of the leap year.
1) By using the calendar module
Initially we learn a little about the calendar module before we go to solve the problem. Calendar module is built into Python which provides us with various functions to solve the date, month and year related problem.
PROGRAM
# importing the module
import calendar
# input the year
year=int(input('Enter the value of year: '))
leap_year=calendar.isleap(year)
# checking leap year
if leap_year: # to check condition
print('The given year is a leap year.')
else:
print('The given year is a non-leap year.')
Output
RUN 1:
Enter the value of year: 2020
The given year is a leap year.
RUN 2:
Enter the value of year: 2021
The given year is a non-leap year.
2) By simply checking method
As we know it is a leap year, or not, to test the year in question. So, we'll introduce the condition here and try to write the Python programme.
Program
# input the year
y=int(input('Enter the value of year: '))
# To check for non century year
if y%400==0 or y%4==0 and y%100!=0:
print('The given year is a leap year.')
else:
print('The given year is a non-leap year.')
Output
RUN 1:
Enter the value of year: 2020
The given year is a leap year.
RUN 2:
Enter the value of year: 2000
The given year is a leap year.
Python | Some of the examples of simple if else
Example1: Enter a number and check whether it is 10 or not
a=int(input("Enter A : "))
if a==10:
print("Equal to 10")
else:
print("Not Equal to 10")
Output
Enter A : 10
Equal to 10
Example2: Find which is largest of two numbers
a=int(input("Enter A: "))
b=int(input("Enter B: "))
if a>b:
g=a
else:
g=b
print("Greater = ",g)
Output
Enter A: 36
Enter B: 24
Greater = 36
Example3: Find which is largest of two numbers using single statement
a=int(input("Enter A: "))
b=int(input("Enter B: "))
c= a if a>b else b
print("Greater = ",c)
Output
Enter A: 24
Enter B: 36
Greater = 36
Calculate discount based on the sale amount in Python
The discount rates are:
Amount Discount
0-5000 5%
5000-15000 12%
15000-25000 20%
above 25000 30%
Program:
# input sale amount
amt = int(input("Enter Sale Amount: "))
# checking conditions and calculating discount
if(amt>0):
if amt<=5000:
disc = amt*0.05
elif amt<=15000:
disc=amt*0.12
elif amt<=25000:
disc=0.2 * amt
else:
disc=0.3 * amt
print("Discount : ",disc)
print("Net Pay : ",amt-disc)
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Python Coding and C Programming Examples: Programming for Stupid»

Look at similar books to Python Coding and C Programming Examples: Programming for Stupid. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Python Coding and C Programming Examples: Programming for Stupid»

Discussion, reviews of the book Python Coding and C Programming Examples: Programming for Stupid and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.